Skip to content

Commit f6d3780

Browse files
committed
Reset indicator after leaving chat
1 parent b19983c commit f6d3780

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/ConversationScreen.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.foundation.layout.padding
1111
import androidx.compose.material3.VerticalDivider
1212
import androidx.compose.runtime.Composable
13+
import androidx.compose.runtime.DisposableEffect
1314
import androidx.compose.runtime.LaunchedEffect
1415
import androidx.compose.runtime.getValue
1516
import androidx.compose.runtime.mutableStateOf
@@ -50,6 +51,10 @@ fun ConversationScreen(
5051
viewModel.updateOpenedThread(threadPostId)
5152
}
5253

54+
DisposableEffect(viewModel) {
55+
onDispose { viewModel.chatListUseCase.resetLastAlreadyReadPostId() }
56+
}
57+
5358
val showThread by remember(threadPostId) {
5459
mutableStateOf(threadPostId != null)
5560
}

feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/ConversationChatListUseCase.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ class ConversationChatListUseCase(
120120
// We store this in addition to the unreadPostCount, because as new posts come in, the unreadPostCount will become outdated.
121121
private var lastAlreadyReadPostId: Long? = null
122122

123+
fun resetLastAlreadyReadPostId() {
124+
lastAlreadyReadPostId = null
125+
}
126+
123127
@OptIn(ExperimentalPagingApi::class)
124128
val postPagingData: Flow<PagingData<ChatListItem>> =
125129
pagingDataInput.flatMapLatest { pagingDataInput ->

0 commit comments

Comments
 (0)