mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 12:00:03 +03:00
Improve hidden events for threads
This commit is contained in:
parent
cfa52d83b4
commit
877c9bec97
3 changed files with 13 additions and 6 deletions
|
@ -84,6 +84,7 @@ import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
|
|||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||
import org.matrix.android.sdk.api.session.events.model.isThread
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||
|
@ -106,6 +107,7 @@ import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
|||
import org.matrix.android.sdk.api.util.MimeTypes
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||
import org.matrix.android.sdk.internal.database.lightweight.LightweightSettingsStorage
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageItemFactory @Inject constructor(
|
||||
|
@ -125,6 +127,7 @@ class MessageItemFactory @Inject constructor(
|
|||
private val noticeItemFactory: NoticeItemFactory,
|
||||
private val avatarSizeProvider: AvatarSizeProvider,
|
||||
private val pillsPostProcessorFactory: PillsPostProcessor.Factory,
|
||||
private val lightweightSettingsStorage: LightweightSettingsStorage,
|
||||
private val spanUtils: SpanUtils,
|
||||
private val session: Session,
|
||||
private val voiceMessagePlaybackTracker: VoiceMessagePlaybackTracker,
|
||||
|
@ -168,6 +171,11 @@ class MessageItemFactory @Inject constructor(
|
|||
return noticeItemFactory.create(params)
|
||||
}
|
||||
|
||||
// This is a thread event and we will [debug] display it when we are in the main timeline
|
||||
if (lightweightSettingsStorage.areThreadMessagesEnabled() && !params.isFromThreadTimeline() && event.root.isThread()) {
|
||||
return noticeItemFactory.create(params)
|
||||
}
|
||||
|
||||
// always hide summary when we are on thread timeline
|
||||
val attributes = messageItemAttributesFactory.create(messageContent, informationData, callback, threadDetails)
|
||||
|
||||
|
@ -200,10 +208,6 @@ class MessageItemFactory @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun isFromThreadTimeline(params: TimelineItemFactoryParams) {
|
||||
params.rootThreadEventId
|
||||
}
|
||||
|
||||
private fun buildLocationItem(locationContent: MessageLocationContent,
|
||||
informationData: MessageInformationData,
|
||||
highlight: Boolean,
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.extensions.appendNl
|
|||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.isThread
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
|
@ -104,6 +105,7 @@ class NoticeEventFormatter @Inject constructor(
|
|||
EventType.STATE_SPACE_CHILD,
|
||||
EventType.STATE_SPACE_PARENT,
|
||||
EventType.REDACTION,
|
||||
EventType.STICKER,
|
||||
EventType.POLL_RESPONSE,
|
||||
EventType.POLL_END -> formatDebug(timelineEvent.root)
|
||||
else -> {
|
||||
|
@ -194,7 +196,8 @@ class NoticeEventFormatter @Inject constructor(
|
|||
}
|
||||
|
||||
private fun formatDebug(event: Event): CharSequence {
|
||||
return "Debug: event type \"${event.getClearType()}\""
|
||||
val threadPrefix = if (event.isThread()) "thread" else ""
|
||||
return "Debug: $threadPrefix event type \"${event.getClearType()}\""
|
||||
}
|
||||
|
||||
private fun formatRoomCreateEvent(event: Event, isDm: Boolean): CharSequence? {
|
||||
|
|
|
@ -117,7 +117,7 @@ class TimelineEventVisibilityHelper @Inject constructor(private val userPreferen
|
|||
rootThreadEventId: String?
|
||||
): Boolean {
|
||||
// If show hidden events is true we should always display something
|
||||
if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
||||
if (userPreferencesProvider.shouldShowHiddenEvents() && !isFromThreadTimeline) {
|
||||
return true
|
||||
}
|
||||
// We always show highlighted event
|
||||
|
|
Loading…
Reference in a new issue