commit 3990ad83e3b90f8a75f4d2d3febff161c955e65d
parent 87acbbac53e25e83a336d8a0af2b93dc524c41c0
Author: t3sserakt <t3ss@posteo.de>
Date: Wed, 29 Apr 2026 14:04:17 +0200
fix the message disapearance
Diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt
@@ -486,11 +486,15 @@ class MainActivity : AppCompatActivity() {
fun clearChatState() {
chatOverviewViewModel.clearModel()
contactListViewModel.clearModel()
- chatViewModels.values.forEach { it.clearModel() }
- chatViewModels.clear()
- chatMenuViewModels.clear()
+ // Intentionally keep chatViewModels and chatMenuViewModels across
+ // account switches. The per-chat message log is in-memory only, and
+ // the daemon does not replay history on (re)connect. Wiping them
+ // here makes A's messages vanish the moment we switch to B. The
+ // stable chat key (group:<name> / contact:<key>) is identity-
+ // independent, so the same ViewModel is still the correct sink for
+ // future TEXT callbacks under account B.
chats.clear()
- Log.d(TAG, "clearChatState: all chat state cleared")
+ Log.d(TAG, "clearChatState: chat overview/contacts cleared, message history preserved")
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {