Add history sharing badges to room details (#5043)

* chore: Add dependency `SwiftFlow` for use in avatar header badges.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>

* feat: Display history sharing pill in room details.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>

* tests: Add tests for history sharing room details pill.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>

* tests: Update screenshots for RoomDetailsScreen preview tests.

* fix: Use Localazy translations for room details badges

* fix: Address review comments

* fix: Remove line limit from room details badges

---------

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
This commit is contained in:
Skye Elliot
2026-02-11 12:22:39 +00:00
committed by GitHub
parent 992cec91d6
commit 4841a3bdaf
57 changed files with 333 additions and 67 deletions
@@ -746,4 +746,53 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
try await deferred.fulfill()
}
// MARK: - History Sharing
func testHistorySharingPillDoesNotAppearIfFeatureFlagNotSet() async throws {
ServiceLocator.shared.settings.enableKeyShareOnInvite = false
let configuration = JoinedRoomProxyMockConfiguration(historyVisibility: .shared)
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(RoomInfoProxyMock(configuration))
let roomProxyMock = JoinedRoomProxyMock(configuration)
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
userSession: UserSessionMock(.init()),
analyticsService: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxyMock,
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
appSettings: ServiceLocator.shared.settings)
let deferredInvisible = deferFailure(context.observe(\.viewState),
timeout: 1,
message: "The pill should not be shown as the feature flag is not set") { state in
state.details.historySharingState != nil
}
try await deferredInvisible.fulfill()
}
func testHistorySharingPillDisplayedIfHistoryVisibilityShared() async throws {
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
let configuration = JoinedRoomProxyMockConfiguration(historyVisibility: .shared)
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(RoomInfoProxyMock(configuration))
let roomProxyMock = JoinedRoomProxyMock(configuration)
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
userSession: UserSessionMock(.init()),
analyticsService: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxyMock,
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
appSettings: ServiceLocator.shared.settings)
let deferredShared = deferFulfillment(context.observe(\.viewState),
message: "The pill should be shown for rooms with shared history visibility") { state in
state.details.historySharingState == .shared
}
try await deferredShared.fulfill()
}
}