diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt index 6058564b78..b63656dc50 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomSummary.kt @@ -98,11 +98,11 @@ data class RoomSummary( */ val highlightCount: Int = 0, /** - * Number of threads with unread messages in this room + * Number of threads with unread messages in this room. */ val threadNotificationCount: Int = 0, /** - * Number of threads with highlighted messages in this room + * Number of threads with highlighted messages in this room. */ val threadHighlightCount: Int = 0, /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt index 0651b8f3d8..7eb44c1350 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt @@ -48,7 +48,7 @@ data class RoomSync( @Json(name = "unread_notifications") val unreadNotifications: RoomSyncUnreadNotifications? = null, /** - * The count of threads with unread notifications (not the total # of notifications in all threads) + * The count of threads with unread notifications (not the total # of notifications in all threads). */ @Json(name = "unread_thread_notifications") val unreadThreadNotifications: Map? = null, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt index 082acb63ab..fd6acea71d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt @@ -75,7 +75,9 @@ internal data class RoomEventFilter( */ @Json(name = "contains_url") val containsUrl: Boolean? = null, /** - * If true, enables lazy-loading of membership events. See Lazy-loading room members for more information. Defaults to false. + * If true, enables lazy-loading of membership events. + * See Lazy-loading room members for more information. + * Defaults to false. */ @Json(name = "lazy_load_members") val lazyLoadMembers: Boolean? = null, /** diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index a019ab862d..62f3cad5aa 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -408,11 +408,12 @@ class TimelineViewModel @AssistedInject constructor( * Observe local unread threads. */ private fun observeLocalThreadNotifications() { + if (room == null) return val threadNotificationsSupported = session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreadReadReceiptsAndNotifications if (threadNotificationsSupported) { - room?.getRoomSummaryLive() - ?.asFlow() - ?.onEach { + room.getRoomSummaryLive() + .asFlow() + .onEach { it.getOrNull()?.let { setState { copy( @@ -424,15 +425,15 @@ class TimelineViewModel @AssistedInject constructor( } } } - ?.launchIn(viewModelScope) + .launchIn(viewModelScope) } else { - room?.flow() - ?.liveLocalUnreadThreadList() - ?.execute { + room.flow() + .liveLocalUnreadThreadList() + .execute { val threadList = it.invoke() val isUserMentioned = threadList?.firstOrNull { threadRootEvent -> threadRootEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE - }?.let { true } ?: false + } != null val numberOfLocalUnreadThreads = threadList?.size ?: 0 copy( threadNotificationBadgeState = ThreadNotificationBadgeState(