ios: allow to reply in another chat without losing draft

This commit is contained in:
Evgeny Poberezkin
2023-01-26 23:28:56 +00:00
parent 22b7aa90b2
commit 148261a1ee

View File

@@ -76,20 +76,12 @@ struct ChatView: View {
.onChange(of: chatModel.chatId) { _ in
if chatModel.chatId == nil { dismiss() }
}
.onChange(of: "\(composeState.empty) \(composeState.noPreview) \(composeState.message)") { _ in
if !composeState.empty {
chatModel.draft = composeState
chatModel.draftChatId = chat.id
} else if chatModel.draftChatId == chat.id {
chatModel.draft = nil
chatModel.draftChatId = nil
}
}
.onDisappear {
if chatModel.chatId == cInfo.id {
chatModel.chatId = nil
if chatModel.draftChatId == cInfo.id {
if !composeState.empty {
chatModel.draft = composeState
chatModel.draftChatId = chat.id
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
if chatModel.chatId == nil {