Do not show history visible banner when the user cannot send messages. (#4892)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user