mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 02:54:34 +00:00
desktop: fix forwarding moving message draft to another chat (#7307)
* desktop: fix forwarding moving message draft to another chat The same ComposeView is reused when switching chats, so the `chat` captured by the desktop-only `onDispose` is the chat that was open when the view was first composed, not the one the message is forwarded from. The draft was saved under that stale chat id, and when it happened to be the chat forwarded to, sending the forward restored the draft there. * plan: justify desktop forward/draft fix and cross-platform findings
This commit is contained in:
+3
-1
@@ -1352,12 +1352,14 @@ fun ComposeView(
|
||||
composeState.value = composeState.value.copy(maxFileSize = getMaxFileSize(FileProtocol.XFTP, if (incognito) null else chatModel.currentUser.value?.profile))
|
||||
}
|
||||
if (appPlatform.isDesktop) {
|
||||
// the same ComposeView is reused when switching chats, so `chat` captured by onDispose would be the chat opened first, not the current one
|
||||
val currentChatId = rememberUpdatedState(chat.id)
|
||||
// Don't enable this on Android, it breaks it, This method only works on desktop. For Android there is a `KeyChangeEffect(chatModel.chatId.value)`
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
if (chatModel.sharedContent.value is SharedContent.Forward && saveLastDraft && !composeState.value.empty) {
|
||||
chatModel.draft.value = composeState.value
|
||||
chatModel.draftChatId.value = chat.id
|
||||
chatModel.draftChatId.value = currentChatId.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user