android: fix notifications to open correct chat (#692)

* android: fix notifications to open correct chat

* remove optimization
This commit is contained in:
Evgeny Poberezkin
2022-05-23 18:33:28 +01:00
committed by GitHub
parent 3051732622
commit 4a42797d83

View File

@@ -40,6 +40,7 @@ class MainActivity: ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// testJson()
processNotificationIntent(intent, vm.chatModel)
setContent {
SimpleXTheme {
Surface(
@@ -105,11 +106,11 @@ fun MainPage(chatModel: ChatModel) {
}
}
fun processIntent(intent: Intent?, chatModel: ChatModel) {
fun processNotificationIntent(intent: Intent?, chatModel: ChatModel) {
when (intent?.action) {
NtfManager.OpenChatAction -> {
val chatId = intent.getStringExtra("chatId")
Log.d(TAG, "processIntent: OpenChatAction $chatId")
Log.d(TAG, "processNotificationIntent: OpenChatAction $chatId")
if (chatId != null) {
val cInfo = chatModel.getChat(chatId)?.chatInfo
chatModel.clearOverlays.value = true
@@ -117,9 +118,15 @@ fun processIntent(intent: Intent?, chatModel: ChatModel) {
}
}
NtfManager.ShowChatsAction -> {
Log.d(TAG, "processIntent: ShowChatsAction")
Log.d(TAG, "processNotificationIntent: ShowChatsAction")
chatModel.chatId.value = null
chatModel.clearOverlays.value = true
}
}
}
fun processIntent(intent: Intent?, chatModel: ChatModel) {
when (intent?.action) {
"android.intent.action.VIEW" -> {
val uri = intent.data
if (uri != null) connectIfOpenedViaUri(uri, chatModel)