Add typealias for TimelineEvent

This commit is contained in:
ariskotsomitopoulos 2022-01-20 00:50:44 +02:00
parent 38f193fbd5
commit 35ee72aac0
4 changed files with 10 additions and 8 deletions

View File

@ -32,6 +32,8 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.util.Optional import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.api.util.toOptional import org.matrix.android.sdk.api.util.toOptional
typealias ThreadRootEvent = TimelineEvent
class FlowRoom(private val room: Room) { class FlowRoom(private val room: Room) {
fun liveRoomSummary(): Flow<Optional<RoomSummary>> { fun liveRoomSummary(): Flow<Optional<RoomSummary>> {
@ -99,14 +101,14 @@ class FlowRoom(private val room: Room) {
return room.getLiveRoomNotificationState().asFlow() return room.getLiveRoomNotificationState().asFlow()
} }
fun liveThreadList(): Flow<List<TimelineEvent>> { fun liveThreadList(): Flow<List<ThreadRootEvent>> {
return room.getAllThreadsLive().asFlow() return room.getAllThreadsLive().asFlow()
.startWith(room.coroutineDispatchers.io) { .startWith(room.coroutineDispatchers.io) {
room.getAllThreads() room.getAllThreads()
} }
} }
fun liveLocalUnreadThreadList(): Flow<List<TimelineEvent>> { fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> {
return room.getNumberOfLocalThreadNotificationsLive().asFlow() return room.getNumberOfLocalThreadNotificationsLive().asFlow()
.startWith(room.coroutineDispatchers.io) { .startWith(room.coroutineDispatchers.io) {
room.getNumberOfLocalThreadNotifications() room.getNumberOfLocalThreadNotifications()

View File

@ -326,8 +326,8 @@ class TimelineViewModel @AssistedInject constructor(
.liveLocalUnreadThreadList() .liveLocalUnreadThreadList()
.execute { .execute {
val threadList = it.invoke() val threadList = it.invoke()
val isUserMentioned = threadList?.firstOrNull { timelineEvent -> val isUserMentioned = threadList?.firstOrNull { threadRootEvent ->
timelineEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE threadRootEvent.root.threadDetails?.threadNotificationState == ThreadNotificationState.NEW_HIGHLIGHTED_MESSAGE
}?.let { true } ?: false }?.let { true } ?: false
val numberOfLocalUnreadThreads = threadList?.size ?: 0 val numberOfLocalUnreadThreads = threadList?.size ?: 0
copy(threadNotificationBadgeState = ThreadNotificationBadgeState( copy(threadNotificationBadgeState = ThreadNotificationBadgeState(

View File

@ -62,9 +62,9 @@ class ThreadListViewModel @AssistedInject constructor(@Assisted val initialState
room?.flow() room?.flow()
?.liveThreadList() ?.liveThreadList()
?.map { ?.map {
it.map { timelineEvent -> it.map { threadRootEvent ->
val isParticipating = room.isUserParticipatingInThread(timelineEvent.eventId) val isParticipating = room.isUserParticipatingInThread(threadRootEvent.eventId)
ThreadTimelineEvent(timelineEvent, isParticipating) ThreadTimelineEvent(threadRootEvent, isParticipating)
} }
} }
?.flowOn(room.coroutineDispatchers.io) ?.flowOn(room.coroutineDispatchers.io)

View File

@ -41,7 +41,7 @@ class VectorSettingsLabsFragment @Inject constructor(
// clear cache // clear cache
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_ENABLE_THREAD_MESSAGES)?.let { findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_ENABLE_THREAD_MESSAGES)?.let {
it.onPreferenceClickListener = Preference.OnPreferenceClickListener { pref-> it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled()) lightweightSettingsStorage.setThreadMessagesEnabled(vectorPreferences.areThreadMessagesEnabled())
displayLoadingView() displayLoadingView()
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true))