PR remarks

This commit is contained in:
ariskotsomitopoulos 2022-02-01 12:13:10 +02:00
parent 15fe9edfbd
commit fcc095a239
7 changed files with 37 additions and 37 deletions

View file

@ -109,9 +109,9 @@ class FlowRoom(private val room: Room) {
} }
fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> { fun liveLocalUnreadThreadList(): Flow<List<ThreadRootEvent>> {
return room.getNumberOfLocalThreadNotificationsLive().asFlow() return room.getMarkedThreadNotificationsLive().asFlow()
.startWith(room.coroutineDispatchers.io) { .startWith(room.coroutineDispatchers.io) {
room.getNumberOfLocalThreadNotifications() room.getMarkedThreadNotifications()
} }
} }
} }

View file

@ -20,33 +20,30 @@ import androidx.lifecycle.LiveData
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
/** /**
* This interface defines methods to interact with threads related features. It's implemented at the room level within the main timeline. * This interface defines methods to interact with threads related features.
* It's implemented at the room level within the main timeline.
*/ */
interface ThreadsService { interface ThreadsService {
/** /**
* Get a live list of all the TimelineEvents which have thread replies for the specified roomId * Returns a [LiveData] list of all the thread root TimelineEvents that exists at the room level
* @return the [LiveData] of [TimelineEvent]
*/ */
fun getAllThreadsLive(): LiveData<List<TimelineEvent>> fun getAllThreadsLive(): LiveData<List<TimelineEvent>>
/** /**
* Get a list of all the TimelineEvents which have thread replies for the specified roomId * Returns a list of all the thread root TimelineEvents that exists at the room level
* @return the [LiveData] of [TimelineEvent]
*/ */
fun getAllThreads(): List<TimelineEvent> fun getAllThreads(): List<TimelineEvent>
/** /**
* Get a live list of all the local unread threads for the specified roomId * Returns a [LiveData] list of all the marked unread threads that exists at the room level
* @return the [LiveData] of [TimelineEvent]
*/ */
fun getNumberOfLocalThreadNotificationsLive(): LiveData<List<TimelineEvent>> fun getMarkedThreadNotificationsLive(): LiveData<List<TimelineEvent>>
/** /**
* Get a list of all the local unread threads for the specified roomId * Returns a list of all the marked unread threads that exists at the room level
* @return the [LiveData] of [TimelineEvent]
*/ */
fun getNumberOfLocalThreadNotifications(): List<TimelineEvent> fun getMarkedThreadNotifications(): List<TimelineEvent>
/** /**
* Returns whether or not the current user is participating in the thread * Returns whether or not the current user is participating in the thread
@ -55,14 +52,16 @@ interface ThreadsService {
fun isUserParticipatingInThread(rootThreadEventId: String): Boolean fun isUserParticipatingInThread(rootThreadEventId: String): Boolean
/** /**
* Enhance the thread list with the edited events if needed * Enhance the provided root thread TimelineEvent [List] by adding the latest
* @return the [LiveData] of [TimelineEvent] * message edition for that thread
* @return the enhanced [List] with edited updates
*/ */
fun mapEventsWithEdition(threads: List<TimelineEvent>): List<TimelineEvent> fun mapEventsWithEdition(threads: List<TimelineEvent>): List<TimelineEvent>
/** /**
* Marks the current thread as read. This is a local implementation * Marks the current thread as read in local DB.
* @param rootThreadEventId the eventId of the current thread * note: read receipts within threads are not yet supported with the API
* @param rootThreadEventId the root eventId of the current thread
*/ */
suspend fun markThreadAsRead(rootThreadEventId: String) suspend fun markThreadAsRead(rootThreadEventId: String)
} }

View file

@ -159,7 +159,7 @@ internal fun TimelineEventEntity.Companion.findAllThreadsForRoomId(realm: Realm,
.sort("${TimelineEventEntityFields.ROOT.THREAD_SUMMARY_LATEST_MESSAGE}.${TimelineEventEntityFields.ROOT.ORIGIN_SERVER_TS}", Sort.DESCENDING) .sort("${TimelineEventEntityFields.ROOT.THREAD_SUMMARY_LATEST_MESSAGE}.${TimelineEventEntityFields.ROOT.ORIGIN_SERVER_TS}", Sort.DESCENDING)
/** /**
* Map each timelineEvent with the equivalent decrypted text edition/replacement for root threads * Map each root thread TimelineEvent with the equivalent decrypted text edition/replacement
*/ */
internal fun List<TimelineEvent>.mapEventsWithEdition(realm: Realm, roomId: String): List<TimelineEvent> = internal fun List<TimelineEvent>.mapEventsWithEdition(realm: Realm, roomId: String): List<TimelineEvent> =
this.map { this.map {
@ -180,8 +180,8 @@ internal fun List<TimelineEvent>.mapEventsWithEdition(realm: Realm, roomId: Stri
} }
/** /**
* Find the number of all the local notifications for the specified room * Returns a list of all the marked unread threads that exists for the specified room
* @param roomId The room that the number of notifications will be returned * @param roomId The roomId that the user is currently in
*/ */
internal fun TimelineEventEntity.Companion.findAllLocalThreadNotificationsForRoomId(realm: Realm, roomId: String): RealmQuery<TimelineEventEntity> = internal fun TimelineEventEntity.Companion.findAllLocalThreadNotificationsForRoomId(realm: Realm, roomId: String): RealmQuery<TimelineEventEntity> =
TimelineEventEntity TimelineEventEntity

View file

@ -49,14 +49,14 @@ internal class DefaultThreadsService @AssistedInject constructor(
fun create(roomId: String): DefaultThreadsService fun create(roomId: String): DefaultThreadsService
} }
override fun getNumberOfLocalThreadNotificationsLive(): LiveData<List<TimelineEvent>> { override fun getMarkedThreadNotificationsLive(): LiveData<List<TimelineEvent>> {
return monarchy.findAllMappedWithChanges( return monarchy.findAllMappedWithChanges(
{ TimelineEventEntity.findAllLocalThreadNotificationsForRoomId(it, roomId = roomId) }, { TimelineEventEntity.findAllLocalThreadNotificationsForRoomId(it, roomId = roomId) },
{ timelineEventMapper.map(it) } { timelineEventMapper.map(it) }
) )
} }
override fun getNumberOfLocalThreadNotifications(): List<TimelineEvent> { override fun getMarkedThreadNotifications(): List<TimelineEvent> {
return monarchy.fetchAllMappedSync( return monarchy.fetchAllMappedSync(
{ TimelineEventEntity.findAllLocalThreadNotificationsForRoomId(it, roomId = roomId) }, { TimelineEventEntity.findAllLocalThreadNotificationsForRoomId(it, roomId = roomId) },
{ timelineEventMapper.map(it) } { timelineEventMapper.map(it) }

View file

@ -417,14 +417,13 @@ class CommandParser @Inject constructor() {
* @return The command that is not supported * @return The command that is not supported
*/ */
private fun getNotSupportedByThreads(isInThreadTimeline: Boolean, slashCommand: String): Command? { private fun getNotSupportedByThreads(isInThreadTimeline: Boolean, slashCommand: String): Command? {
if (isInThreadTimeline) { return if (isInThreadTimeline) {
notSupportedThreadsCommands.firstOrNull { notSupportedThreadsCommands.firstOrNull {
it.command == slashCommand it.command == slashCommand
}?.let {
return it
} }
} else {
null
} }
return null
} }
private fun trimParts(message: CharSequence, messageParts: List<String>): String? { private fun trimParts(message: CharSequence, messageParts: List<String>): String? {

View file

@ -1924,17 +1924,16 @@ class TimelineFragment @Inject constructor(
timelineViewModel.handle(action) timelineViewModel.handle(action)
} }
is EncryptedEventContent -> { is EncryptedEventContent -> {
if (isRootThreadEvent) {
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)
} else {
timelineViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId)) timelineViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId))
}
} }
is MessageLocationContent -> { is MessageLocationContent -> {
handleShowLocationPreview(messageContent, informationData.senderId) handleShowLocationPreview(messageContent, informationData.senderId)
} }
else -> { else -> {
onThreadSummaryClicked(informationData.eventId, isRootThreadEvent) val handled = onThreadSummaryClicked(informationData.eventId, isRootThreadEvent)
if (!handled) {
Timber.d("No click action defined for this message content")
}
} }
} }
} }
@ -1966,9 +1965,12 @@ class TimelineFragment @Inject constructor(
} }
} }
override fun onThreadSummaryClicked(eventId: String, isRootThreadEvent: Boolean) { override fun onThreadSummaryClicked(eventId: String, isRootThreadEvent: Boolean): Boolean {
if (vectorPreferences.areThreadMessagesEnabled() && isRootThreadEvent && !isThreadTimeLine()) { return if (vectorPreferences.areThreadMessagesEnabled() && isRootThreadEvent && !isThreadTimeLine()) {
navigateToThreadTimeline(eventId) navigateToThreadTimeline(eventId)
true
} else {
false
} }
} }
@ -2361,7 +2363,7 @@ class TimelineFragment @Inject constructor(
} }
} }
// VectorInviteView.Callback // VectorInviteView.Callback
override fun onAcceptInvite() { override fun onAcceptInvite() {
notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(timelineArgs.roomId) } notificationDrawerManager.updateEvents { it.clearMemberShipNotificationForRoom(timelineArgs.roomId) }
timelineViewModel.handle(RoomDetailAction.AcceptInvite) timelineViewModel.handle(RoomDetailAction.AcceptInvite)
@ -2381,7 +2383,7 @@ class TimelineFragment @Inject constructor(
} }
} }
// AttachmentTypeSelectorView.Callback // AttachmentTypeSelectorView.Callback
private val typeSelectedActivityResultLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> private val typeSelectedActivityResultLauncher = registerForPermissionsResult { allGranted, deniedPermanently ->
if (allGranted) { if (allGranted) {
val pendingType = attachmentsHelper.pendingType val pendingType = attachmentsHelper.pendingType
@ -2431,7 +2433,7 @@ class TimelineFragment @Inject constructor(
}.exhaustive }.exhaustive
} }
// AttachmentsHelper.Callback // AttachmentsHelper.Callback
override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) { override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) {
val grouped = attachments.toGroupedContentAttachmentData() val grouped = attachments.toGroupedContentAttachmentData()
if (grouped.notPreviewables.isNotEmpty()) { if (grouped.notPreviewables.isNotEmpty()) {

View file

@ -156,7 +156,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
} }
interface ThreadCallback { interface ThreadCallback {
fun onThreadSummaryClicked(eventId: String, isRootThreadEvent: Boolean) fun onThreadSummaryClicked(eventId: String, isRootThreadEvent: Boolean) : Boolean
} }
interface ReadReceiptsCallback { interface ReadReceiptsCallback {