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.notificationCount = unreadNotifications?.notificationCount ?: 0
|
||||||
|
|
||||||
roomSummaryEntity.threadHighlightCount = unreadThreadNotifications
|
roomSummaryEntity.threadHighlightCount = unreadThreadNotifications
|
||||||
?.map { it.value.highlightCount.takeIf { count -> (count ?: 0) > 0 } }
|
?.count { (it.value.highlightCount ?: 0) > 0 }
|
||||||
?.size
|
|
||||||
?: 0
|
|
||||||
roomSummaryEntity.threadNotificationCount = unreadThreadNotifications
|
|
||||||
?.map { it.value.notificationCount.takeIf { count -> (count ?: 0) > 0 } }
|
|
||||||
?.size
|
|
||||||
?: 0
|
?: 0
|
||||||
|
|
||||||
|
roomSummaryEntity.threadNotificationCount = unreadThreadNotifications
|
||||||
|
?.count { (it.value.notificationCount ?: 0) > 0 }
|
||||||
|
?: 0
|
||||||
|
|
||||||
if (membership != null) {
|
if (membership != null) {
|
||||||
roomSummaryEntity.membership = membership
|
roomSummaryEntity.membership = membership
|
||||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.features.home.room.detail
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
|
import androidx.lifecycle.asFlow
|
||||||
import com.airbnb.mvrx.Async
|
import com.airbnb.mvrx.Async
|
||||||
import com.airbnb.mvrx.Fail
|
import com.airbnb.mvrx.Fail
|
||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
|
@ -407,10 +408,27 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
* Observe local unread threads.
|
* Observe local unread threads.
|
||||||
*/
|
*/
|
||||||
private fun observeLocalThreadNotifications() {
|
private fun observeLocalThreadNotifications() {
|
||||||
if (room == null) return
|
val threadNotificationsSupported = session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreadReadReceiptsAndNotifications
|
||||||
room.flow()
|
if (threadNotificationsSupported) {
|
||||||
.liveLocalUnreadThreadList()
|
room?.getRoomSummaryLive()
|
||||||
.execute {
|
?.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 threadList = it.invoke()
|
||||||
val isUserMentioned = threadList?.firstOrNull { threadRootEvent ->
|
val isUserMentioned = threadList?.firstOrNull { threadRootEvent ->
|
||||||
threadRootEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE
|
threadRootEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE
|
||||||
|
@ -424,6 +442,7 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun handle(action: RoomDetailAction) {
|
override fun handle(action: RoomDetailAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
|
|
Loading…
Reference in New Issue