From accd28f9f4fd25252d6a3a63960af77af80b0393 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 14:11:36 +0300 Subject: [PATCH] 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. --- bitchat/Views/ContentView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bitchat/Views/ContentView.swift b/bitchat/Views/ContentView.swift index fb77e698..f6fdf05b 100644 --- a/bitchat/Views/ContentView.swift +++ b/bitchat/Views/ContentView.swift @@ -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) } }