refactor: mark as read on open and use less buffer time

This commit is contained in:
0x330a 2023-05-01 09:15:03 +10:00
parent d207d00423
commit ac736744f6

View file

@ -440,8 +440,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
// only update the conversation every 3 seconds maximum
// channel is rendezvous and shouldn't block on try send calls as often as we want
withContext(Dispatchers.IO) {
storage.markConversationAsRead(viewModel.threadId, SnodeAPI.nowWithOffset)
}
val bufferedFlow = bufferedLastSeenChannel.consumeAsFlow()
.debounce(30.seconds)
bufferedFlow.collectLatest {
withContext(Dispatchers.IO) {
storage.markConversationAsRead(viewModel.threadId, SnodeAPI.nowWithOffset)
@ -496,7 +498,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (author != null && messageTimestamp >= 0) {
jumpToMessage(author, messageTimestamp, null)
}
// TODO: buffer this
bufferedLastSeenChannel.trySend(Unit)
}
updatePlaceholder()