Skip to content

Commit

Permalink
Hide "X made no changes" event by default in timeline (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Jun 2, 2020
1 parent 1b95d98 commit 3f1e5b9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Features ✨:

Improvements 🙌:
- New wording for notice when current user is the sender
- Hide "X made no changes" event by default in timeline (#1430)

Bugfix 🐛:
- Switch theme is not fully taken into account without restarting the app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ data class TimelineSettings(
* A flag to filter redacted events
*/
val filterRedacted: Boolean = false,
/**
* A flag to filter useless events, such as membership events without any change
*/
val filterUseless: Boolean = false,
/**
* A flag to filter by types. It should be used with [allowedTypes] field
*/
Expand All @@ -44,5 +48,4 @@ data class TimelineSettings(
* If true, will build read receipts for each event.
*/
val buildReadReceipts: Boolean = true

)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package im.vector.matrix.android.internal.database.mapper
import com.squareup.moshi.JsonDataException
import im.vector.matrix.android.api.session.crypto.MXCryptoError
import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.events.model.EventType
import im.vector.matrix.android.api.session.events.model.UnsignedData
import im.vector.matrix.android.api.session.room.send.SendState
import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult
Expand All @@ -38,6 +39,7 @@ internal object EventMapper {
eventEntity.content = ContentMapper.map(event.content)
val resolvedPrevContent = event.prevContent ?: event.unsignedData?.prevContent
eventEntity.prevContent = ContentMapper.map(resolvedPrevContent)
eventEntity.isUseless = event.type == EventType.STATE_ROOM_MEMBER && eventEntity.content == eventEntity.prevContent
eventEntity.stateKey = event.stateKey
eventEntity.type = event.type
eventEntity.sender = event.senderId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal open class EventEntity(@Index var eventId: String = "",
@Index var type: String = "",
var content: String? = null,
var prevContent: String? = null,
var isUseless: Boolean = false,
@Index var stateKey: String? = null,
var originServerTs: Long? = null,
@Index var sender: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ internal class DefaultTimeline(
if (settings.filterTypes) {
`in`(TimelineEventEntityFields.ROOT.TYPE, settings.allowedTypes.toTypedArray())
}
if (settings.filterUseless) {
not().equalTo(TimelineEventEntityFields.ROOT.IS_USELESS, true)
}
if (settings.filterEdits) {
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.EDIT)
not().like(TimelineEventEntityFields.ROOT.CONTENT, TimelineEventFilter.Content.RESPONSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu
not().`in`("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.TYPE}", settings.allowedTypes.toTypedArray())
needOr = true
}
if (settings.filterUseless) {
if (needOr) or()
equalTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.IS_USELESS}", true)
needOr = true
}
if (settings.filterEdits) {
if (needOr) or()
like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.CONTENT}", TimelineEventFilter.Content.EDIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ class RoomDetailViewModel @AssistedInject constructor(
TimelineSettings(30,
filterEdits = false,
filterRedacted = userPreferencesProvider.shouldShowRedactedMessages().not(),
filterUseless = false,
filterTypes = false,
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
} else {
TimelineSettings(30,
filterEdits = true,
filterRedacted = userPreferencesProvider.shouldShowRedactedMessages().not(),
filterUseless = true,
filterTypes = true,
allowedTypes = TimelineDisplayableEvents.DISPLAYABLE_TYPES,
buildReadReceipts = userPreferencesProvider.shouldShowReadReceipts())
Expand Down

0 comments on commit 3f1e5b9

Please sign in to comment.