mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add a banner to encrypted rooms with visible history. (#4851)
* Add a banner to encrypted rooms with visible history. (#4738) * feat: Add history visible alert. - Adds a dismissable alert that is displayed whenever the user opens a room with `history_visibility` != `joined`. When cleared, this is recorded in the app's data store. - When opening a room with `history_visibility` = `joined`, this flag is cleared. Issue: element-hq/element-meta#2875 * tests: Add unit tests for history sharing in `RoomScreenFooterView`. * feat: Rename flag to `hasSeenHistoryVisibleBannerRooms`, document. * refactor: Merge enum variants, use function for banner description. * feat: Use `AppSettings.historyVisibleDetailsURL` over hard-coded value. * tests: Correct potential race condition with deferred assertion. * chore: Use Localazy translation string over project-defined. * fix: Final tweaks and review comments. * chore: Checkout `Enterprise` submodule. * tests: Final fixes. * fix: Condition banner visibility on feature flag state. * fix: Prioritise identity violations over history visibility banner. * tests: Add snapshots for history visible banner. * tests: Use deferred failure timeout for improved test power. * chore: Tweaks to spelling, simplify state logic. * fix: Remove "g". * fix: Show banner for shared/world-readable rooms, not invited. * refactor: Use `else-if` instead of `if`.
This commit is contained in:
@@ -101,6 +101,9 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
Task { await resolveIdentityPinningViolation(userID) }
|
||||
case .resolveVerificationViolation(let userID):
|
||||
Task { await resolveIdentityVerificationViolation(userID) }
|
||||
case .dismissHistoryVisibleAlert:
|
||||
appSettings.acknowledgedHistoryVisibleRooms.insert(roomProxy.id)
|
||||
state.historyVisibleDetails = nil
|
||||
}
|
||||
case .acceptKnock(let eventID):
|
||||
Task { await acceptKnock(eventID: eventID) }
|
||||
@@ -244,13 +247,13 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
}
|
||||
|
||||
if let member = identityVerificationViolations.values.first {
|
||||
state.footerDetails = .verificationViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
state.identityViolationDetails = .verificationViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
} else if let member = identityPinningViolations.values.first {
|
||||
state.footerDetails = .pinViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
state.identityViolationDetails = .pinViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
} else {
|
||||
state.footerDetails = nil
|
||||
state.identityViolationDetails = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +345,20 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
state.canDeclineKnocks = powerLevels.canOwnUserKick()
|
||||
state.canBan = powerLevels.canOwnUserBan()
|
||||
}
|
||||
|
||||
let isHistoryVisible = roomInfo.historyVisibility == .shared || roomInfo.historyVisibility == .worldReadable
|
||||
let isHistoryVisibleBannerAcknowledged = appSettings.acknowledgedHistoryVisibleRooms.contains(roomInfo.id)
|
||||
|
||||
if appSettings.enableKeyShareOnInvite, roomInfo.isEncrypted {
|
||||
if isHistoryVisible, !isHistoryVisibleBannerAcknowledged {
|
||||
// Whenever the user opens an encrypted room with shared/world-readable history visbility, we show them a warning banner if they have not already dismissed it.
|
||||
state.historyVisibleDetails = .historyVisible(learnMoreURL: appSettings.historySharingDetailsURL)
|
||||
} else if !isHistoryVisible, isHistoryVisibleBannerAcknowledged {
|
||||
// Whenever the user opens a room with non-shared history visibility, we clear the dismiss flag to ensure that the banner is displayed again if the history is made visible in the future.
|
||||
appSettings.acknowledgedHistoryVisibleRooms.remove(roomInfo.id)
|
||||
state.historyVisibleDetails = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func setupPinnedEventsTimelineItemProviderIfNeeded() {
|
||||
|
||||
Reference in New Issue
Block a user