Code improvements

This commit is contained in:
ericdecanini 2022-10-24 10:31:55 -04:00
parent 35be56a44a
commit 3673e720fa
4 changed files with 15 additions and 12 deletions

View File

@ -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,
/**

View File

@ -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<String, RoomSyncUnreadThreadNotifications>? = null,

View File

@ -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,
/**

View File

@ -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(