Commit 390a3cd 1 parent d43cd76 commit 390a3cd Copy full SHA for 390a3cd
File tree 3 files changed +9
-11
lines changed
app/src/main/java/com/infomaniak/mail/ui/main/thread
3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -352,20 +352,15 @@ class ThreadFragment : Fragment() {
352
352
mainViewModel.toggleLightThemeForMessage.observe(viewLifecycleOwner, threadAdapter::toggleLightMode)
353
353
}
354
354
355
- private fun observeThreadLive () = with (threadViewModel) {
355
+ private fun observeThreadLive () {
356
356
357
- threadLive.observe(viewLifecycleOwner) { thread ->
357
+ threadViewModel. threadLive.observe(viewLifecycleOwner) { thread ->
358
358
359
359
if (thread == null ) {
360
360
twoPaneViewModel.closeThread()
361
361
return @observe
362
362
}
363
363
364
- if (threadState.shouldMarkThreadAsSeen == true ) {
365
- threadState.shouldMarkThreadAsSeen = false
366
- markThreadAsSeen(thread)
367
- }
368
-
369
364
binding.iconFavorite.apply {
370
365
setIconResource(if (thread.isFavorite) R .drawable.ic_star_filled else R .drawable.ic_star)
371
366
val color = if (thread.isFavorite) {
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ThreadState {
37
37
val isCalendarEventExpandedMap: MutableMap <String , Boolean > = mutableMapOf ()
38
38
val treatedMessagesForCalendarEvent: MutableSet <String > = mutableSetOf ()
39
39
val cachedSplitBodies: MutableMap <String , SplitBody > = mutableMapOf ()
40
- var shouldMarkThreadAsSeen : Boolean? = null
40
+ var hasBeenMarkedAsSeen : Boolean = false
41
41
var superCollapsedBlock: SuperCollapsedBlock ? = null
42
42
43
43
fun reset () {
@@ -48,7 +48,7 @@ class ThreadState {
48
48
isCalendarEventExpandedMap.clear()
49
49
treatedMessagesForCalendarEvent.clear()
50
50
cachedSplitBodies.clear()
51
- shouldMarkThreadAsSeen = null
51
+ hasBeenMarkedAsSeen = false
52
52
superCollapsedBlock = null
53
53
}
54
54
}
Original file line number Diff line number Diff line change @@ -255,12 +255,15 @@ class ThreadViewModel @Inject constructor(
255
255
}
256
256
}
257
257
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
+ }
259
262
260
263
emit(thread)
261
264
}
262
265
263
- fun markThreadAsSeen (thread : Thread ) = viewModelScope.launch(ioCoroutineContext) {
266
+ private fun markThreadAsSeen (thread : Thread ) = viewModelScope.launch(ioCoroutineContext) {
264
267
sharedUtils.markAsSeen(mailbox, listOf (thread))
265
268
}
266
269
You can’t perform that action at this time.
0 commit comments