mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-29 07:27:16 +00:00
fix: clear in-memory composer draft on panic wipe
ComposerDraftStore.reset() alone left messageText in ContentView, so the next background transition could persist the pre-wipe draft again.
This commit is contained in:
parent
f9c8878d02
commit
accd28f9f4
@ -236,6 +236,11 @@ struct ContentView: View {
|
||||
}
|
||||
appChromeModel.setPanicPreparation { [weak voiceRecordingVM] in
|
||||
voiceRecordingVM?.panicWipe()
|
||||
// Drop in-memory composer text before ChatViewModel resets
|
||||
// persisted drafts — otherwise the next inactive/background
|
||||
// transition would write the pre-wipe draft back.
|
||||
messageText = ""
|
||||
activeDraftKey = .mesh
|
||||
}
|
||||
#if os(macOS)
|
||||
DispatchQueue.main.async {
|
||||
@ -284,6 +289,10 @@ struct ContentView: View {
|
||||
}
|
||||
.onChange(of: scenePhase) { phase in
|
||||
if phase == .background || phase == .inactive {
|
||||
// Skip persist when the composer was already cleared (e.g.
|
||||
// panic wipe): otherwise a half-written message would be
|
||||
// written back after ComposerDraftStore.reset().
|
||||
guard !messageText.isEmpty else { return }
|
||||
ComposerDraftStore.save(messageText, for: activeDraftKey)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user