mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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 historyVisibleDetails: RoomScreenFooterViewDetails?
|
||||||
|
|
||||||
var footerDetails: RoomScreenFooterViewDetails? {
|
var footerDetails: RoomScreenFooterViewDetails? {
|
||||||
identityViolationDetails ?? historyVisibleDetails
|
if let identityViolationDetails {
|
||||||
|
return identityViolationDetails
|
||||||
|
}
|
||||||
|
guard canSendMessage else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return historyVisibleDetails
|
||||||
}
|
}
|
||||||
|
|
||||||
var bindings = RoomScreenViewStateBindings()
|
var bindings = RoomScreenViewStateBindings()
|
||||||
|
|||||||
@@ -554,6 +554,38 @@ class RoomScreenViewModelTests: XCTestCase {
|
|||||||
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
let deferred = deferFailure(viewModel.context.$viewState, timeout: 1) { $0.footerDetails != nil }
|
||||||
try await deferred.fulfill()
|
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 {
|
func testHistoryVisibleBannerAppearsThenDisappearsOnAcknowledge() async throws {
|
||||||
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
ServiceLocator.shared.settings.enableKeyShareOnInvite = true
|
||||||
|
|||||||
Reference in New Issue
Block a user