Do not show history visible banner when the user cannot send messages. (#4892)

This commit is contained in:
Skye Elliot
2026-01-06 16:36:19 +00:00
committed by GitHub
parent a78a923b0d
commit 6117ee3a2b
2 changed files with 39 additions and 1 deletions

View File

@@ -84,7 +84,13 @@ struct RoomScreenViewState: BindableState {
var historyVisibleDetails: RoomScreenFooterViewDetails?
var footerDetails: RoomScreenFooterViewDetails? {
identityViolationDetails ?? historyVisibleDetails
if let identityViolationDetails {
return identityViolationDetails
}
guard canSendMessage else {
return nil
}
return historyVisibleDetails
}
var bindings = RoomScreenViewStateBindings()

View File

@@ -554,6 +554,38 @@ class RoomScreenViewModelTests: XCTestCase {
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
try await deferred.fulfill()
}
func testHistoryVisibleBannerDoesNotAppearIfCannotSendMessages() async throws {
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
ServiceLocator.shared.settings.acknowledgedHistoryVisibleRooms = Set()
let powerlevels = RoomPowerLevelsProxyMockConfiguration(
canUserSendMessage: false
)
let configuration = JoinedRoomProxyMockConfiguration(id: "$room:example.com", isEncrypted: true, powerLevelsConfiguration: powerlevels)
let roomProxyMock = JoinedRoomProxyMock(configuration)
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
roomInfoProxyMock.historyVisibility = .shared
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(roomInfoProxyMock)
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
let viewModel = RoomScreenViewModel(userSession: UserSessionMock(.init()),
roomProxy: roomProxyMock,
initialSelectedPinnedEventID: nil,
ongoingCallRoomIDPublisher: .init(.init(nil)),
appSettings: ServiceLocator.shared.settings,
appHooks: AppHooks(),
analyticsService: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
self.viewModel = viewModel
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
try await deferred.fulfill()
}
func testHistoryVisibleBannerAppearsThenDisappearsOnAcknowledge() async throws {
ServiceLocator.shared.settings.enableKeyShareOnInvite = true