File tree Expand file tree Collapse file tree 3 files changed +9
-11
lines changed
app/src/main/java/com/infomaniak/mail/ui/main/thread Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -352,20 +352,15 @@ class ThreadFragment : Fragment() {
352352 mainViewModel.toggleLightThemeForMessage.observe(viewLifecycleOwner, threadAdapter::toggleLightMode)
353353 }
354354
355- private fun observeThreadLive () = with (threadViewModel) {
355+ private fun observeThreadLive () {
356356
357- threadLive.observe(viewLifecycleOwner) { thread ->
357+ threadViewModel. threadLive.observe(viewLifecycleOwner) { thread ->
358358
359359 if (thread == null ) {
360360 twoPaneViewModel.closeThread()
361361 return @observe
362362 }
363363
364- if (threadState.shouldMarkThreadAsSeen == true ) {
365- threadState.shouldMarkThreadAsSeen = false
366- markThreadAsSeen(thread)
367- }
368-
369364 binding.iconFavorite.apply {
370365 setIconResource(if (thread.isFavorite) R .drawable.ic_star_filled else R .drawable.ic_star)
371366 val color = if (thread.isFavorite) {
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ThreadState {
3737 val isCalendarEventExpandedMap: MutableMap <String , Boolean > = mutableMapOf ()
3838 val treatedMessagesForCalendarEvent: MutableSet <String > = mutableSetOf ()
3939 val cachedSplitBodies: MutableMap <String , SplitBody > = mutableMapOf ()
40- var shouldMarkThreadAsSeen : Boolean? = null
40+ var hasBeenMarkedAsSeen : Boolean = false
4141 var superCollapsedBlock: SuperCollapsedBlock ? = null
4242
4343 fun reset () {
@@ -48,7 +48,7 @@ class ThreadState {
4848 isCalendarEventExpandedMap.clear()
4949 treatedMessagesForCalendarEvent.clear()
5050 cachedSplitBodies.clear()
51- shouldMarkThreadAsSeen = null
51+ hasBeenMarkedAsSeen = false
5252 superCollapsedBlock = null
5353 }
5454}
Original file line number Diff line number Diff line change @@ -255,12 +255,15 @@ class ThreadViewModel @Inject constructor(
255255 }
256256 }
257257
258- if (threadState.shouldMarkThreadAsSeen == null ) threadState.shouldMarkThreadAsSeen = thread.unseenMessagesCount > 0
258+ if (! threadState.hasBeenMarkedAsSeen) {
259+ threadState.hasBeenMarkedAsSeen = true
260+ if (thread.unseenMessagesCount > 0 ) markThreadAsSeen(thread)
261+ }
259262
260263 emit(thread)
261264 }
262265
263- fun markThreadAsSeen (thread : Thread ) = viewModelScope.launch(ioCoroutineContext) {
266+ private fun markThreadAsSeen (thread : Thread ) = viewModelScope.launch(ioCoroutineContext) {
264267 sharedUtils.markAsSeen(mailbox, listOf (thread))
265268 }
266269
You can’t perform that action at this time.
0 commit comments