Skip to content

Commit 5147916

Browse files
fix(unread): Don't restore scroll position when interaction with a converation (like makr as (un)read)
AI-assistant: Copilot 1.0.10 (Claude Sonnet 4.6) Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent ed1b95d commit 5147916

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class ConversationsListActivity : BaseActivity() {
142142
// Lazy list state – set from inside setContent, read from onPause
143143
private var conversationListLazyListState: androidx.compose.foundation.lazy.LazyListState? = null
144144

145+
// Ensures saved scroll position is restored only once per resume cycle, not on every room-list refresh.
146+
private var scrollPositionRestored = false
147+
145148
private var nextUnreadConversationScrollPosition = 0
146149
private var credentials: String? = null
147150
private val showShareToScreenState = MutableStateFlow(false)
@@ -298,6 +301,7 @@ class ConversationsListActivity : BaseActivity() {
298301

299302
override fun onResume() {
300303
super.onResume()
304+
scrollPositionRestored = false
301305

302306
showNotificationWarningState.value = shouldShowNotificationWarning()
303307
showShareToScreenState.value = hasActivityActionSendIntent()
@@ -364,9 +368,12 @@ class ConversationsListActivity : BaseActivity() {
364368
val isNoteToSelfAvailable = noteToSelf != null
365369
handleNoteToSelfShortcut(isNoteToSelfAvailable, noteToSelf?.token ?: "")
366370

367-
val pair = appPreferences.conversationListPositionAndOffset
368-
lifecycleScope.launch {
369-
conversationListLazyListState?.scrollToItem(pair.first, pair.second)
371+
if (!scrollPositionRestored) {
372+
scrollPositionRestored = true
373+
val pair = appPreferences.conversationListPositionAndOffset
374+
lifecycleScope.launch {
375+
conversationListLazyListState?.scrollToItem(pair.first, pair.second)
376+
}
370377
}
371378
}.collect()
372379
}

0 commit comments

Comments
 (0)