Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state events for pinning and unpinning #3123

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading