Fixes thread notifications instantly disappearing
This commit is contained in:
parent
dc7bff10c1
commit
1086ed367e
|
@ -114,14 +114,12 @@ internal class RoomSummaryUpdater @Inject constructor(
|
|||
roomSummaryEntity.notificationCount = unreadNotifications?.notificationCount ?: 0
|
||||
|
||||
roomSummaryEntity.threadHighlightCount = unreadThreadNotifications
|
||||
?.map { it.value.highlightCount.takeIf { count -> (count ?: 0) > 0 } }
|
||||
?.size
|
||||
?: 0
|
||||
roomSummaryEntity.threadNotificationCount = unreadThreadNotifications
|
||||
?.map { it.value.notificationCount.takeIf { count -> (count ?: 0) > 0 } }
|
||||
?.size
|
||||
?.count { (it.value.highlightCount ?: 0) > 0 }
|
||||
?: 0
|
||||
|
||||
roomSummaryEntity.threadNotificationCount = unreadThreadNotifications
|
||||
?.count { (it.value.notificationCount ?: 0) > 0 }
|
||||
?: 0
|
||||
|
||||
if (membership != null) {
|
||||
roomSummaryEntity.membership = membership
|
||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail
|
|||
|
||||
import android.net.Uri
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.lifecycle.asFlow
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.Loading
|
||||
|
@ -407,10 +408,27 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
* Observe local unread threads.
|
||||
*/
|
||||
private fun observeLocalThreadNotifications() {
|
||||
if (room == null) return
|
||||
room.flow()
|
||||
.liveLocalUnreadThreadList()
|
||||
.execute {
|
||||
val threadNotificationsSupported = session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreadReadReceiptsAndNotifications
|
||||
if (threadNotificationsSupported) {
|
||||
room?.getRoomSummaryLive()
|
||||
?.asFlow()
|
||||
?.onEach {
|
||||
it.getOrNull()?.let {
|
||||
setState {
|
||||
copy(
|
||||
threadNotificationBadgeState = ThreadNotificationBadgeState(
|
||||
numberOfLocalUnreadThreads = it.threadNotificationCount + it.threadHighlightCount,
|
||||
isUserMentioned = it.threadHighlightCount > 0,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
?.launchIn(viewModelScope)
|
||||
} else {
|
||||
room?.flow()
|
||||
?.liveLocalUnreadThreadList()
|
||||
?.execute {
|
||||
val threadList = it.invoke()
|
||||
val isUserMentioned = threadList?.firstOrNull { threadRootEvent ->
|
||||
threadRootEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE
|
||||
|
@ -424,6 +442,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun handle(action: RoomDetailAction) {
|
||||
when (action) {
|
||||
|
|
Loading…
Reference in New Issue