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.toOptional
typealias ThreadRootEvent = TimelineEvent
class FlowRoom(private val room: Room) {
fun liveRoomSummary(): Flow<Optional<RoomSummary>> {
@ -99,14 +101,14 @@ class FlowRoom(private val room: Room) {
return room.getLiveRoomNotificationState().asFlow()
}
fun liveThreadList(): Flow<List<TimelineEvent>> {
fun liveThreadList(): Flow<List<ThreadRootEvent>> {
return room.getAllThreadsLive().asFlow()
.startWith(room.coroutineDispatchers.io) {
room.getAllThreads()
}
}
fun liveLocalUnreadThreadList(): Flow<List<TimelineEvent>> {
fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> {
return room.getNumberOfLocalThreadNotificationsLive().asFlow()
.startWith(room.coroutineDispatchers.io) {
room.getNumberOfLocalThreadNotifications()

View file

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

View file

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

View file

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