Skip to content

Commit

Permalink
state events for pinning and unpinning (#3123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 authored Aug 6, 2024
1 parent e2712f6 commit a39a8f9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 32 deletions.
56 changes: 32 additions & 24 deletions ElementX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "9a9d116e5f00b31ad4f727d0875fed13a230806b",
"version" : "1.0.32"
"revision" : "2f11bfecae2c83218fea4336361cabcf3a899a78",
"version" : "1.0.33"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct DeveloperOptionsScreen: View {
Section("Message Pinning") {
Toggle(isOn: $context.pinningEnabled) {
Text("Enable message pinning")
Text("WIP - uses mocked content")
Text("Requires app reboot")
}
}

Expand Down
10 changes: 7 additions & 3 deletions ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,12 @@ class ClientProxy: ClientProxyProtocol {
})
}

private let eventFilters: TimelineEventTypeFilter = {
let stateEventFilters: [StateEventType] = [.roomAliases,
private lazy var eventFilters: TimelineEventTypeFilter = {
var stateEventFilters: [StateEventType] = [.roomAliases,
.roomCanonicalAlias,
.roomGuestAccess,
.roomHistoryVisibility,
.roomJoinRules,
.roomPinnedEvents,
.roomPowerLevels,
.roomServerAcl,
.roomTombstone,
Expand All @@ -855,6 +854,11 @@ class ClientProxy: ClientProxyProtocol {
.policyRuleServer,
.policyRuleUser]

// Reminder: once the feature flag is not required anymore, change the lazy var back to a let
if !appSettings.pinningEnabled {
stateEventFilters.append(.roomPinnedEvents)
}

return .exclude(eventTypes: stateEventFilters.map { FilterTimelineEventType.state(eventType: $0) })
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ struct RoomStateEventStringBuilder {
case (nil, true):
return L10n.stateEventRoomTopicRemovedByYou
}
case .roomPinnedEvents(let change):
switch change {
case .added:
return isOutgoing ? L10n.stateEventRoomPinnedEventsPinnedByYou : L10n.stateEventRoomPinnedEventsPinned(displayName)
case .changed:
return isOutgoing ? L10n.stateEventRoomPinnedEventsChangedByYou : L10n.stateEventRoomPinnedEventsChanged(displayName)
case .removed:
return isOutgoing ? L10n.stateEventRoomPinnedEventsUnpinnedByYou : L10n.stateEventRoomPinnedEventsUnpinned(displayName)
}
case .roomPowerLevels: // Long term we might show only the user changes, but we need an SDK filter to fix read receipts in that case.
break
case .policyRuleRoom, .policyRuleServer, .policyRuleUser: // No strings available.
Expand All @@ -197,7 +206,7 @@ struct RoomStateEventStringBuilder {
break
case .roomJoinRules: // Doesn't provide information about the change.
break
case .roomPinnedEvents, .roomServerAcl: // Doesn't provide information about the change.
case .roomServerAcl: // Doesn't provide information about the change.
break
case .roomTombstone: // Handle as a virtual timeline item with a link to the upgraded room.
break
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ packages:
# Element/Matrix dependencies
MatrixRustSDK:
url: https://github.com/element-hq/matrix-rust-components-swift
exactVersion: 1.0.32
exactVersion: 1.0.33
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios
Expand Down

0 comments on commit a39a8f9

Please sign in to comment.