Display an icon in the room header for rooms with shared history (#5016)

* feat: Display an icon in the room header for rooms with shared history

* fix: Apply suggestions from code review

- Simplifies `isRoomHistoryShared` expressions using type inferrence.
- Adds failure messages to unit test.

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* fix: Remove extension method in favour of field on configuration.

* fix: Distinguish between `shared` and `worldReadable` icons.

* refactor: Use `RoomHistorySharingState` enum with extension methods

---------

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Skye Elliot
2026-01-30 13:11:10 +00:00
committed by GitHub
parent 26cb30c614
commit 955ec0c8a9
15 changed files with 180 additions and 11 deletions
@@ -0,0 +1,15 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
/// Enumeration of the two possible cases in which history sharing under MSC4268 is enabled. These
/// variants implicitly assume that the feature flag, `enableKeyShareOnInvite`, is set.
enum RoomHistorySharingState: Equatable {
/// The feature flag is set, and the room history visibility is set to `shared`.
case shared
/// The feature flag is set, and the room history visibility is set to `world_readable`.
case worldReadable
}
@@ -134,4 +134,20 @@ extension RoomInfoProxyProtocol {
// And finally return whatever the first alternative alias is
return alternativeAliases.first
}
/// If present, the state of history sharing in this room. This *does not* consider the `enableKeyShareOnInvite`
/// feature flag, so consumers should be careful to check the flag is true before utilising this property.
var historySharingState: RoomHistorySharingState? {
guard isEncrypted else {
return nil
}
return switch historyVisibility {
case .shared:
.shared
case .worldReadable:
.worldReadable
default:
nil
}
}
}