mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:06:00 +00:00
Display an icon in the room header for rooms with shared history (#5016)
* feat: Display an icon in the room header for rooms with shared history * fix: Apply suggestions from code review - Simplifies `isRoomHistoryShared` expressions using type inferrence. - Adds failure messages to unit test. Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com> * fix: Remove extension method in favour of field on configuration. * fix: Distinguish between `shared` and `worldReadable` icons. * refactor: Use `RoomHistorySharingState` enum with extension methods --------- Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import OrderedCollections
|
||||
|
||||
enum RoomScreenViewModelAction: Equatable {
|
||||
@@ -80,6 +81,9 @@ struct RoomScreenViewState: BindableState {
|
||||
(canAcceptKnocks || canDeclineKnocks || canBan)
|
||||
}
|
||||
|
||||
/// If `enableKeyShareOnInvite` is set, determines the current history sharing state.
|
||||
var roomHistorySharingState: RoomHistorySharingState?
|
||||
|
||||
var footerDetails: RoomScreenFooterViewDetails?
|
||||
|
||||
var bindings = RoomScreenViewStateBindings()
|
||||
|
||||
@@ -67,10 +67,17 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
self.initialSelectedPinnedEventID = initialSelectedPinnedEventID
|
||||
pinnedEventStringBuilder = .pinnedEventStringBuilder(userID: roomProxy.ownUserID)
|
||||
|
||||
let roomHistorySharingState: RoomHistorySharingState? = if appSettings.enableKeyShareOnInvite {
|
||||
roomProxy.infoPublisher.value.historySharingState
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
|
||||
let viewState = RoomScreenViewState(roomTitle: roomProxy.infoPublisher.value.displayName ?? roomProxy.id,
|
||||
roomAvatar: roomProxy.infoPublisher.value.avatar,
|
||||
hasOngoingCall: roomProxy.infoPublisher.value.hasRoomCall,
|
||||
hasSuccessor: roomProxy.infoPublisher.value.successor != nil)
|
||||
hasSuccessor: roomProxy.infoPublisher.value.successor != nil,
|
||||
roomHistorySharingState: roomHistorySharingState)
|
||||
super.init(initialViewState: appHooks.roomScreenHook.update(viewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -342,6 +349,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
state.canDeclineKnocks = powerLevels.canOwnUserKick()
|
||||
state.canBan = powerLevels.canOwnUserBan()
|
||||
}
|
||||
|
||||
// This causes the UI to become inconsistent with the user's mental model if the user
|
||||
// does not restart the app after disabling the feature flag. We can probably ignore
|
||||
// such cases, since we explicitly ask for an app restart in the caption of the feature
|
||||
// flag switch.
|
||||
if appSettings.enableKeyShareOnInvite {
|
||||
state.roomHistorySharingState = roomInfo.historySharingState
|
||||
}
|
||||
}
|
||||
|
||||
private func setupPinnedEventsTimelineItemProviderIfNeeded() {
|
||||
|
||||
@@ -157,6 +157,7 @@ struct RoomScreen: View {
|
||||
RoomHeaderView(roomName: context.viewState.roomTitle,
|
||||
roomAvatar: context.viewState.roomAvatar,
|
||||
dmRecipientVerificationState: context.viewState.dmRecipientVerificationState,
|
||||
roomHistorySharingState: context.viewState.roomHistorySharingState,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
context.send(viewAction: .displayRoomDetails)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ struct ThreadTimelineScreenViewState: BindableState {
|
||||
var roomAvatar: RoomAvatar
|
||||
var canSendMessage = true
|
||||
var dmRecipientVerificationState: UserIdentityVerificationState?
|
||||
var roomHistorySharingState: RoomHistorySharingState?
|
||||
|
||||
var bindings = ThreadTimelineScreenViewStateBindings()
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ struct ThreadTimelineScreen: View {
|
||||
roomSubtitle: context.viewState.roomTitle,
|
||||
roomAvatar: context.viewState.roomAvatar,
|
||||
dmRecipientVerificationState: context.viewState.dmRecipientVerificationState,
|
||||
roomHistorySharingState: context.viewState.roomHistorySharingState,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
// There is no action but the iOS 26 designs have it looking like a button.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user