Merge pull request #3276 from element-hq/feature/fga/render_m.room.pinned_events
[Feature] Pinned message : render m.room.pinned events in timeline
This commit is contained in:
commit
86045e364e
6 changed files with 48 additions and 14 deletions
|
|
@ -31,7 +31,6 @@ object TimelineConfig {
|
||||||
StateEventType.ROOM_GUEST_ACCESS,
|
StateEventType.ROOM_GUEST_ACCESS,
|
||||||
StateEventType.ROOM_HISTORY_VISIBILITY,
|
StateEventType.ROOM_HISTORY_VISIBILITY,
|
||||||
StateEventType.ROOM_JOIN_RULES,
|
StateEventType.ROOM_JOIN_RULES,
|
||||||
StateEventType.ROOM_PINNED_EVENTS,
|
|
||||||
StateEventType.ROOM_POWER_LEVELS,
|
StateEventType.ROOM_POWER_LEVELS,
|
||||||
StateEventType.ROOM_SERVER_ACL,
|
StateEventType.ROOM_SERVER_ACL,
|
||||||
StateEventType.ROOM_TOMBSTONE,
|
StateEventType.ROOM_TOMBSTONE,
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
|
||||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||||
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
||||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.36"
|
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.37"
|
||||||
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
||||||
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
||||||
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,15 @@ class StateContentFormatter @Inject constructor(
|
||||||
else -> sp.getString(R.string.state_event_room_topic_removed, senderDisambiguatedDisplayName)
|
else -> sp.getString(R.string.state_event_room_topic_removed, senderDisambiguatedDisplayName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is OtherState.RoomPinnedEvents -> when (renderingMode) {
|
||||||
|
RenderingMode.RoomList -> {
|
||||||
|
Timber.v("Filtering timeline item for room state change: $content")
|
||||||
|
null
|
||||||
|
}
|
||||||
|
RenderingMode.Timeline -> {
|
||||||
|
formatRoomPinnedEvents(content, senderIsYou, senderDisambiguatedDisplayName)
|
||||||
|
}
|
||||||
|
}
|
||||||
is OtherState.Custom -> when (renderingMode) {
|
is OtherState.Custom -> when (renderingMode) {
|
||||||
RenderingMode.RoomList -> {
|
RenderingMode.RoomList -> {
|
||||||
Timber.v("Filtering timeline item for room state change: $content")
|
Timber.v("Filtering timeline item for room state change: $content")
|
||||||
|
|
@ -161,15 +170,6 @@ class StateContentFormatter @Inject constructor(
|
||||||
"RoomJoinRules"
|
"RoomJoinRules"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OtherState.RoomPinnedEvents -> when (renderingMode) {
|
|
||||||
RenderingMode.RoomList -> {
|
|
||||||
Timber.v("Filtering timeline item for room state change: $content")
|
|
||||||
null
|
|
||||||
}
|
|
||||||
RenderingMode.Timeline -> {
|
|
||||||
"RoomPinnedEvents"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is OtherState.RoomUserPowerLevels -> when (renderingMode) {
|
is OtherState.RoomUserPowerLevels -> when (renderingMode) {
|
||||||
RenderingMode.RoomList -> {
|
RenderingMode.RoomList -> {
|
||||||
Timber.v("Filtering timeline item for room state change: $content")
|
Timber.v("Filtering timeline item for room state change: $content")
|
||||||
|
|
@ -217,4 +217,23 @@ class StateContentFormatter @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun formatRoomPinnedEvents(
|
||||||
|
content: OtherState.RoomPinnedEvents,
|
||||||
|
senderIsYou: Boolean,
|
||||||
|
senderDisambiguatedDisplayName: String
|
||||||
|
) = when (content.change) {
|
||||||
|
OtherState.RoomPinnedEvents.Change.ADDED -> when {
|
||||||
|
senderIsYou -> sp.getString(R.string.state_event_room_pinned_events_pinned_by_you)
|
||||||
|
else -> sp.getString(R.string.state_event_room_pinned_events_pinned, senderDisambiguatedDisplayName)
|
||||||
|
}
|
||||||
|
OtherState.RoomPinnedEvents.Change.REMOVED -> when {
|
||||||
|
senderIsYou -> sp.getString(R.string.state_event_room_pinned_events_unpinned_by_you)
|
||||||
|
else -> sp.getString(R.string.state_event_room_pinned_events_unpinned, senderDisambiguatedDisplayName)
|
||||||
|
}
|
||||||
|
OtherState.RoomPinnedEvents.Change.CHANGED -> when {
|
||||||
|
senderIsYou -> sp.getString(R.string.state_event_room_pinned_events_changed_by_you)
|
||||||
|
else -> sp.getString(R.string.state_event_room_pinned_events_changed, senderDisambiguatedDisplayName)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,7 @@ class DefaultRoomLastMessageFormatterTest {
|
||||||
OtherState.RoomGuestAccess,
|
OtherState.RoomGuestAccess,
|
||||||
OtherState.RoomHistoryVisibility,
|
OtherState.RoomHistoryVisibility,
|
||||||
OtherState.RoomJoinRules,
|
OtherState.RoomJoinRules,
|
||||||
OtherState.RoomPinnedEvents,
|
OtherState.RoomPinnedEvents(OtherState.RoomPinnedEvents.Change.CHANGED),
|
||||||
OtherState.RoomUserPowerLevels(emptyMap()),
|
OtherState.RoomUserPowerLevels(emptyMap()),
|
||||||
OtherState.RoomServerAcl,
|
OtherState.RoomServerAcl,
|
||||||
OtherState.RoomTombstone,
|
OtherState.RoomTombstone,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,14 @@ sealed interface OtherState {
|
||||||
data object RoomHistoryVisibility : OtherState
|
data object RoomHistoryVisibility : OtherState
|
||||||
data object RoomJoinRules : OtherState
|
data object RoomJoinRules : OtherState
|
||||||
data class RoomName(val name: String?) : OtherState
|
data class RoomName(val name: String?) : OtherState
|
||||||
data object RoomPinnedEvents : OtherState
|
data class RoomPinnedEvents(val change: Change) : OtherState {
|
||||||
|
enum class Change {
|
||||||
|
ADDED,
|
||||||
|
REMOVED,
|
||||||
|
CHANGED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class RoomUserPowerLevels(val users: Map<String, Long>) : OtherState
|
data class RoomUserPowerLevels(val users: Map<String, Long>) : OtherState
|
||||||
data object RoomServerAcl : OtherState
|
data object RoomServerAcl : OtherState
|
||||||
data class RoomThirdPartyInvite(val displayName: String?) : OtherState
|
data class RoomThirdPartyInvite(val displayName: String?) : OtherState
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import kotlinx.collections.immutable.toImmutableMap
|
||||||
import org.matrix.rustcomponents.sdk.TimelineItemContent
|
import org.matrix.rustcomponents.sdk.TimelineItemContent
|
||||||
import org.matrix.rustcomponents.sdk.TimelineItemContentKind
|
import org.matrix.rustcomponents.sdk.TimelineItemContentKind
|
||||||
import org.matrix.rustcomponents.sdk.use
|
import org.matrix.rustcomponents.sdk.use
|
||||||
|
import uniffi.matrix_sdk_ui.RoomPinnedEventsChange
|
||||||
import org.matrix.rustcomponents.sdk.EncryptedMessage as RustEncryptedMessage
|
import org.matrix.rustcomponents.sdk.EncryptedMessage as RustEncryptedMessage
|
||||||
import org.matrix.rustcomponents.sdk.MembershipChange as RustMembershipChange
|
import org.matrix.rustcomponents.sdk.MembershipChange as RustMembershipChange
|
||||||
import org.matrix.rustcomponents.sdk.OtherState as RustOtherState
|
import org.matrix.rustcomponents.sdk.OtherState as RustOtherState
|
||||||
|
|
@ -176,7 +177,7 @@ private fun RustOtherState.map(): OtherState {
|
||||||
RustOtherState.RoomHistoryVisibility -> OtherState.RoomHistoryVisibility
|
RustOtherState.RoomHistoryVisibility -> OtherState.RoomHistoryVisibility
|
||||||
RustOtherState.RoomJoinRules -> OtherState.RoomJoinRules
|
RustOtherState.RoomJoinRules -> OtherState.RoomJoinRules
|
||||||
is RustOtherState.RoomName -> OtherState.RoomName(name)
|
is RustOtherState.RoomName -> OtherState.RoomName(name)
|
||||||
RustOtherState.RoomPinnedEvents -> OtherState.RoomPinnedEvents
|
is RustOtherState.RoomPinnedEvents -> OtherState.RoomPinnedEvents(change.map())
|
||||||
is RustOtherState.RoomPowerLevels -> OtherState.RoomUserPowerLevels(users)
|
is RustOtherState.RoomPowerLevels -> OtherState.RoomUserPowerLevels(users)
|
||||||
RustOtherState.RoomServerAcl -> OtherState.RoomServerAcl
|
RustOtherState.RoomServerAcl -> OtherState.RoomServerAcl
|
||||||
is RustOtherState.RoomThirdPartyInvite -> OtherState.RoomThirdPartyInvite(displayName)
|
is RustOtherState.RoomThirdPartyInvite -> OtherState.RoomThirdPartyInvite(displayName)
|
||||||
|
|
@ -187,6 +188,14 @@ private fun RustOtherState.map(): OtherState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun RoomPinnedEventsChange.map(): OtherState.RoomPinnedEvents.Change {
|
||||||
|
return when (this) {
|
||||||
|
RoomPinnedEventsChange.ADDED -> OtherState.RoomPinnedEvents.Change.ADDED
|
||||||
|
RoomPinnedEventsChange.REMOVED -> OtherState.RoomPinnedEvents.Change.REMOVED
|
||||||
|
RoomPinnedEventsChange.CHANGED -> OtherState.RoomPinnedEvents.Change.CHANGED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun RustEncryptedMessage.map(): UnableToDecryptContent.Data {
|
private fun RustEncryptedMessage.map(): UnableToDecryptContent.Data {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is RustEncryptedMessage.MegolmV1AesSha2 -> UnableToDecryptContent.Data.MegolmV1AesSha2(sessionId, cause.map())
|
is RustEncryptedMessage.MegolmV1AesSha2 -> UnableToDecryptContent.Data.MegolmV1AesSha2(sessionId, cause.map())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue