mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Replace AppSettings with UserSettings from the UserSessionFlow and below.
Remove some redundant injections when passed alongside a user session too. # Conflicts: # ElementX/Sources/Screens/PinnedEventsTimelineScreen/View/PinnedEventsTimelineScreen.swift # ElementX/Sources/Screens/Timeline/TimelineViewModel.swift
This commit is contained in:
@@ -14,7 +14,7 @@ struct CallScreenCoordinatorParameters {
|
||||
let elementCallService: ElementCallServiceProtocol
|
||||
let configuration: ElementCallConfiguration
|
||||
let allowPictureInPicture: Bool
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ final class CallScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel = CallScreenViewModel(elementCallService: parameters.elementCallService,
|
||||
configuration: parameters.configuration,
|
||||
allowPictureInPicture: parameters.allowPictureInPicture,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
analyticsService: parameters.analytics)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
private let elementCallService: ElementCallServiceProtocol
|
||||
private let configuration: ElementCallConfiguration
|
||||
private let isPictureInPictureAllowed: Bool
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
|
||||
private let widgetDriver: ElementCallWidgetDriverProtocol
|
||||
@@ -39,11 +39,11 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
init(elementCallService: ElementCallServiceProtocol,
|
||||
configuration: ElementCallConfiguration,
|
||||
allowPictureInPicture: Bool,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
analyticsService: AnalyticsServiceProtocol) {
|
||||
self.elementCallService = elementCallService
|
||||
self.configuration = configuration
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
self.analyticsService = analyticsService
|
||||
isPictureInPictureAllowed = allowPictureInPicture
|
||||
|
||||
@@ -165,13 +165,13 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
||||
|
||||
// We only set the analytics configuration if analytics are enabled
|
||||
let analyticsConfiguration: ElementCallAnalyticsConfiguration? = if analyticsService.isEnabled {
|
||||
.init(posthogAPIHost: appSettings.elementCallPosthogAPIHost,
|
||||
posthogAPIKey: appSettings.elementCallPosthogAPIKey,
|
||||
sentryDSN: appSettings.elementCallPosthogSentryDSN)
|
||||
.init(posthogAPIHost: userSettings.elementCallPosthogAPIHost,
|
||||
posthogAPIKey: userSettings.elementCallPosthogAPIKey,
|
||||
sentryDSN: userSettings.elementCallPosthogSentryDSN)
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
let rageshakeURL: String? = if case let .url(baseURL) = appSettings.bugReportRageshakeURL.publisher.value {
|
||||
let rageshakeURL: String? = if case let .url(baseURL) = userSettings.bugReportRageshakeURL.publisher.value {
|
||||
baseURL.absoluteString
|
||||
} else {
|
||||
nil
|
||||
|
||||
@@ -405,7 +405,7 @@ struct CallScreen_Previews: PreviewProvider {
|
||||
voiceOnly: false,
|
||||
colorScheme: .light),
|
||||
allowPictureInPicture: false,
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ struct CreateRoomScreenCoordinatorParameters {
|
||||
let shouldShowCancelButton: Bool
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class CreateRoomScreenCoordinator: CoordinatorProtocol {
|
||||
userSession: parameters.userSession,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appSettings: parameters.appSettings)
|
||||
userSettings: parameters.userSettings)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -33,9 +33,9 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
|
||||
userSession: UserSessionProtocol,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appSettings: AppSettings) {
|
||||
userSettings: UserSettings) {
|
||||
self.userSession = userSession
|
||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings)
|
||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(userSettings: userSettings)
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -63,7 +63,7 @@ class CreateRoomScreenViewModel: CreateRoomScreenViewModelType, CreateRoomScreen
|
||||
shouldShowCancelButton: shouldShowCancelButton,
|
||||
roomName: "",
|
||||
serverName: userSession.clientProxy.userIDServerName ?? "",
|
||||
isKnockingFeatureEnabled: appSettings.knockingEnabled,
|
||||
isKnockingFeatureEnabled: userSettings.knockingEnabled,
|
||||
canSelectSpace: canSelectSpace,
|
||||
aliasLocalPart: roomAliasNameFromRoomDisplayName(roomName: ""),
|
||||
bindings: bindings),
|
||||
|
||||
@@ -451,8 +451,8 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||
isSpace: Bool = false,
|
||||
selectionMode: CreateRoomScreenSpaceSelectionMode = .editableSpacesList(preSelectedSpace: nil),
|
||||
isAliasAvailable: Bool = true) -> CreateRoomScreenViewModel {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.knockingEnabled = isKnockingEnabled
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.knockingEnabled = isKnockingEnabled
|
||||
|
||||
let clientProxy = ClientProxyMock(.init(userIDServerName: "example.org",
|
||||
userID: "@userid:example.com"))
|
||||
@@ -467,6 +467,6 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||
userSession: userSession,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview
|
||||
clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: .mockJoinedSpaces2))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
return CreateRoomScreenViewModel(isSpace: false,
|
||||
spaceSelectionMode: .editableSpacesList(preSelectedSpace: nil),
|
||||
@@ -73,7 +73,7 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview
|
||||
userSession: userSession,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
@@ -103,7 +103,7 @@ struct EmojiPickerScreen: View {
|
||||
@available(iOS 26.0, *)
|
||||
struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = EmojiPickerScreenViewModel(selectedEmojis: ["😀", "😄"],
|
||||
emojiProvider: EmojiProvider(appSettings: .volatile()),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
continuation: AsyncStream<String>.makeStream().continuation)
|
||||
|
||||
static var previews: some View {
|
||||
@@ -115,7 +115,7 @@ struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
struct EmojiPickerScreenSheet_Previews: PreviewProvider {
|
||||
static let viewModel = EmojiPickerScreenViewModel(selectedEmojis: ["😀", "😄"],
|
||||
emojiProvider: EmojiProvider(appSettings: .volatile()),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
continuation: AsyncStream<String>.makeStream().continuation)
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
@@ -13,7 +13,7 @@ struct HomeScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let bugReportService: BugReportServiceProtocol
|
||||
let selectedRoomPublisher: CurrentValuePublisher<String?, Never>
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analyticsService: AnalyticsServiceProtocol
|
||||
let notificationManager: NotificationManagerProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -50,7 +50,7 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: HomeScreenCoordinatorParameters) {
|
||||
viewModel = HomeScreenViewModel(userSession: parameters.userSession,
|
||||
selectedRoomPublisher: parameters.selectedRoomPublisher,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
analyticsService: parameters.analyticsService,
|
||||
bugReportService: parameters.bugReportService,
|
||||
notificationManager: parameters.notificationManager,
|
||||
|
||||
@@ -18,7 +18,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
private let spaceFilterSubject: CurrentValueSubject<SpaceServiceFilter?, Never>
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let bugReportService: BugReportServiceProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let notificationManager: NotificationManagerProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -32,7 +32,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
// swiftlint:disable:next function_body_length
|
||||
init(userSession: UserSessionProtocol,
|
||||
selectedRoomPublisher: CurrentValuePublisher<String?, Never>,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
bugReportService: BugReportServiceProtocol,
|
||||
notificationManager: NotificationManagerProtocol,
|
||||
@@ -40,7 +40,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
self.userSession = userSession
|
||||
self.analyticsService = analyticsService
|
||||
self.bugReportService = bugReportService
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
self.notificationManager = notificationManager
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -49,10 +49,10 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
roomSummaryProvider = userSession.clientProxy.roomSummaryProvider
|
||||
|
||||
super.init(initialViewState: .init(userProfile: userSession.clientProxy.userProfilePublisher.value,
|
||||
bindings: .init(filtersState: .init(appSettings: appSettings))),
|
||||
bindings: .init(filtersState: .init(userSettings: userSettings))),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
if appSettings.globalSearchEnabled, #available(iOS 26.0, *) {
|
||||
if userSettings.globalSearchEnabled, #available(iOS 26.0, *) {
|
||||
state.isRoomListSearchEnabled = false
|
||||
}
|
||||
|
||||
@@ -113,21 +113,21 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
.weakAssign(to: \.state.selectedRoomID, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.showAllRoomListActivityPublisher
|
||||
userSettings.showAllRoomListActivityPublisher
|
||||
.removeDuplicates()
|
||||
.sink { [weak self] _ in
|
||||
self?.updateRooms()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.seenInvitesPublisher
|
||||
userSettings.seenInvitesPublisher
|
||||
.removeDuplicates()
|
||||
.sink { [weak self] _ in
|
||||
self?.updateRooms()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.hasSeenNewSoundBannerPublisher
|
||||
userSettings.hasSeenNewSoundBannerPublisher
|
||||
.sink { [weak self] hasSeenNewSoundBanner in
|
||||
self?.state.shouldShowNewSoundBanner = !hasSeenNewSoundBanner
|
||||
}
|
||||
@@ -210,7 +210,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
case .skipRecoveryKeyConfirmation:
|
||||
state.securityBannerMode = .dismissed
|
||||
case .dismissNewSoundBanner:
|
||||
appSettings.hasSeenNewSoundBanner = true
|
||||
userSettings.hasSeenNewSoundBanner = true
|
||||
case .updateVisibleItemRange(let range):
|
||||
roomSummaryProvider?.updateVisibleRange(range)
|
||||
case .startChat:
|
||||
@@ -260,7 +260,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
case .success:
|
||||
analyticsService.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle)
|
||||
|
||||
if case .failure(let error) = await roomProxy.markAsRead(receiptType: appSettings.sharePresence ? .read : .readPrivate) {
|
||||
if case .failure(let error) = await roomProxy.markAsRead(receiptType: userSettings.sharePresence ? .read : .readPrivate) {
|
||||
MXLog.error("Failed marking room \(roomIdentifier) as read with error: \(error)")
|
||||
}
|
||||
case .failure(let error):
|
||||
@@ -372,11 +372,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
}
|
||||
|
||||
var rooms = [HomeScreenRoom]()
|
||||
let seenInvites = appSettings.seenInvites
|
||||
let seenInvites = userSettings.seenInvites
|
||||
|
||||
for summary in roomSummaryProvider.roomListPublisher.value {
|
||||
let room = HomeScreenRoom(summary: summary,
|
||||
showAllActivity: appSettings.showAllRoomListActivity,
|
||||
showAllActivity: userSettings.showAllRoomListActivity,
|
||||
seenInvites: seenInvites)
|
||||
rooms.append(room)
|
||||
}
|
||||
@@ -513,7 +513,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
analyticsService.trackJoinedRoom(isDM: roomProxy.info.isDirect,
|
||||
isSpace: roomProxy.info.isSpace,
|
||||
activeMemberCount: UInt(roomProxy.info.activeMembersCount))
|
||||
appSettings.seenInvites.remove(roomProxy.id)
|
||||
userSettings.seenInvites.remove(roomProxy.id)
|
||||
}
|
||||
|
||||
private func showDeclineInviteConfirmationAlert(roomID: String) async {
|
||||
@@ -563,7 +563,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
switch result {
|
||||
case .success:
|
||||
await notificationManager.removeDeliveredMessageNotifications(for: roomID) // Normally handled by the room flow, but that's never presented in this case.
|
||||
appSettings.seenInvites.remove(roomID)
|
||||
userSettings.seenInvites.remove(roomID)
|
||||
case .failure:
|
||||
displayError()
|
||||
}
|
||||
|
||||
@@ -89,21 +89,21 @@ enum RoomListFilter: Int, CaseIterable, Identifiable {
|
||||
|
||||
struct RoomListFiltersState {
|
||||
private(set) var activeFilters: OrderedSet<RoomListFilter>
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
|
||||
init(activeFilters: OrderedSet<RoomListFilter> = [], appSettings: AppSettings) {
|
||||
init(activeFilters: OrderedSet<RoomListFilter> = [], userSettings: UserSettings) {
|
||||
self.activeFilters = .init(activeFilters)
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
}
|
||||
|
||||
var availableFilters: [RoomListFilter] {
|
||||
var availableFilters = OrderedSet(RoomListFilter.availableFilters)
|
||||
|
||||
if !appSettings.lowPriorityFilterEnabled {
|
||||
if !userSettings.lowPriorityFilterEnabled {
|
||||
availableFilters.remove(.lowPriority)
|
||||
}
|
||||
|
||||
if !appSettings.mentionsFilterEnabled {
|
||||
if !userSettings.mentionsFilterEnabled {
|
||||
availableFilters.remove(.mentions)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -61,10 +61,10 @@ struct RoomListFiltersEmptyStateView_Previews: PreviewProvider, TestablePreview
|
||||
VStack(spacing: 24) {
|
||||
ForEach(RoomListFilter.allCases) { filter in
|
||||
RoomListFiltersEmptyStateView(state: .init(activeFilters: [filter],
|
||||
appSettings: .volatile()))
|
||||
userSettings: .volatile()))
|
||||
}
|
||||
RoomListFiltersEmptyStateView(state: .init(activeFilters: [.people, .favourites],
|
||||
appSettings: .volatile()))
|
||||
userSettings: .volatile()))
|
||||
}
|
||||
.padding(.bottom)
|
||||
.previewLayout(.sizeThatFits)
|
||||
|
||||
@@ -92,10 +92,10 @@ struct RoomListFiltersView: View {
|
||||
|
||||
struct RoomListFiltersView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
RoomListFiltersView(state: .constant(.init(appSettings: .volatile())))
|
||||
RoomListFiltersView(state: .constant(.init(userSettings: .volatile())))
|
||||
RoomListFiltersView(state: .constant(.init(activeFilters: [.rooms, .favourites],
|
||||
appSettings: .volatile())))
|
||||
userSettings: .volatile())))
|
||||
RoomListFiltersView(state: .constant(.init(activeFilters: [.lowPriority],
|
||||
appSettings: .volatile())))
|
||||
userSettings: .volatile())))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -145,7 +145,7 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([])))))))
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -201,7 +201,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -133,7 +133,7 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
|
||||
@@ -13,7 +13,7 @@ struct JoinRoomScreenCoordinatorParameters {
|
||||
let source: JoinRoomScreenSource
|
||||
let userSession: UserSessionProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum JoinRoomScreenSource {
|
||||
@@ -53,7 +53,7 @@ final class JoinRoomScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: JoinRoomScreenCoordinatorParameters) {
|
||||
viewModel = JoinRoomScreenViewModel(source: parameters.source,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
userSession: parameters.userSession,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ typealias JoinRoomScreenViewModelType = StateStoreViewModel<JoinRoomScreenViewSt
|
||||
|
||||
class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewModelProtocol {
|
||||
private let source: JoinRoomScreenSource
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -30,11 +30,11 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
}
|
||||
|
||||
init(source: JoinRoomScreenSource,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
userSession: UserSessionProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.source = source
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -52,7 +52,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
.sink { mode in
|
||||
switch mode {
|
||||
case .invited:
|
||||
appSettings.seenInvites.insert(roomID)
|
||||
userSettings.seenInvites.insert(roomID)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@@ -350,7 +350,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
guard !hasSentJoinAction else { return }
|
||||
|
||||
let roomID = state.roomID
|
||||
appSettings.seenInvites.remove(roomID)
|
||||
userSettings.seenInvites.remove(roomID)
|
||||
|
||||
guard state.roomDetails?.isSpace == true else {
|
||||
hasSentJoinAction = true
|
||||
@@ -464,7 +464,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
return false
|
||||
}
|
||||
|
||||
appSettings.seenInvites.remove(roomID)
|
||||
userSettings.seenInvites.remove(roomID)
|
||||
|
||||
actionsSubject.send(.dismiss)
|
||||
return true
|
||||
|
||||
@@ -402,7 +402,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
self.isSpace = isSpace
|
||||
self.customPreviewName = customPreviewName
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
let clientProxy = ClientProxyMock(.init(hideInviteAvatars: hideInviteAvatars))
|
||||
clientProxy.canJoinRoomWithReturnValue = canJoinRoom
|
||||
@@ -455,7 +455,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
}
|
||||
|
||||
viewModel = JoinRoomScreenViewModel(source: source,
|
||||
appSettings: appSettings,
|
||||
userSettings: userSettings,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct LabsScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum LabsScreenCoordinatorAction {
|
||||
@@ -28,7 +28,7 @@ final class LabsScreenCoordinator: CoordinatorProtocol {
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init(parameters: LabsScreenCoordinatorParameters) {
|
||||
viewModel = LabsScreenViewModel(labsOptions: parameters.appSettings)
|
||||
viewModel = LabsScreenViewModel(labsOptions: parameters.userSettings.app)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -15,7 +15,7 @@ struct LocationSharingScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let timelineController: TimelineControllerProtocol
|
||||
let liveLocationManager: LiveLocationManagerProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let appMediator: AppMediatorProtocol
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -45,7 +45,7 @@ final class LocationSharingScreenCoordinator: CoordinatorProtocol {
|
||||
roomProxy: parameters.roomProxy,
|
||||
timelineController: parameters.timelineController,
|
||||
liveLocationManager: parameters.liveLocationManager,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
analytics: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
mediaProvider: parameters.mediaProvider)
|
||||
|
||||
@@ -17,7 +17,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let timelineController: TimelineControllerProtocol
|
||||
private let liveLocationManager: LiveLocationManagerProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let notificationCenter: NotificationCenter
|
||||
@@ -37,7 +37,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
timelineController: TimelineControllerProtocol,
|
||||
liveLocationManager: LiveLocationManagerProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
analytics: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
@@ -45,7 +45,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
self.roomProxy = roomProxy
|
||||
self.timelineController = timelineController
|
||||
self.liveLocationManager = liveLocationManager
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.notificationCenter = notificationCenter
|
||||
@@ -173,7 +173,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.liveLocationSharingSessionsByRoomIDPublisher
|
||||
userSettings.liveLocationSharingSessionsByRoomIDPublisher
|
||||
.map { [roomID = roomProxy.id] sessions in sessions[roomID] != nil }
|
||||
.removeDuplicates()
|
||||
.sink { [weak self] isSharingLiveLocationOnThisDevice in
|
||||
@@ -261,14 +261,14 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
|
||||
}
|
||||
|
||||
private func showLiveLocationFlow() {
|
||||
if appSettings.liveLocationDisclaimerDisplayed {
|
||||
if userSettings.liveLocationDisclaimerDisplayed {
|
||||
showLiveLocationDurationPicker()
|
||||
} else {
|
||||
state.bindings.alertInfo = .init(alertID: .liveLocationDisclaimer,
|
||||
primaryButton: .init(title: L10n.actionDecline, role: .cancel, action: nil),
|
||||
secondaryButton: .init(title: L10n.actionAccept) { [weak self] in
|
||||
guard let self else { return }
|
||||
appSettings.liveLocationDisclaimerDisplayed = true
|
||||
userSettings.liveLocationDisclaimerDisplayed = true
|
||||
// Delay so SwiftUI finishes dismissing the current alert
|
||||
// before presenting the next one.
|
||||
DispatchQueue.main.async {
|
||||
@@ -432,14 +432,14 @@ extension LocationSharingScreenViewModel {
|
||||
let roomProxy = JoinedRoomProxyMock(.init(members: .allMembers, ownUserID: RoomMemberProxyMock.mockMe.userID))
|
||||
roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
return LocationSharingScreenViewModel(interactionMode: interactionMode,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration.publisher.value,
|
||||
mapURLBuilder: userSettings.mapTilerConfiguration.publisher.value,
|
||||
roomProxy: roomProxy,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
liveLocationManager: LiveLocationManagerMock(),
|
||||
appSettings: appSettings,
|
||||
userSettings: userSettings,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(.init()))
|
||||
|
||||
+1
-3
@@ -16,7 +16,7 @@ struct MediaEventsTimelineScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
@@ -46,7 +46,6 @@ final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
mediaPlayerProvider: parameters.mediaPlayerProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appMediator: parameters.appMediator,
|
||||
appSettings: parameters.appSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
emojiProvider: parameters.emojiProvider,
|
||||
linkMetadataProvider: parameters.linkMetadataProvider,
|
||||
@@ -58,7 +57,6 @@ final class MediaEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
mediaPlayerProvider: parameters.mediaPlayerProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appMediator: parameters.appMediator,
|
||||
appSettings: parameters.appSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
emojiProvider: parameters.emojiProvider,
|
||||
linkMetadataProvider: parameters.linkMetadataProvider,
|
||||
|
||||
+1
-3
@@ -307,16 +307,14 @@ struct MediaEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {
|
||||
makeTimelineController(screenMode: screenMode)
|
||||
}
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")),
|
||||
timelineController: timelineController,
|
||||
userSession: UserSessionMock(.init(contentScannerService: contentScannerService)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}
|
||||
|
||||
+1
-1
@@ -393,7 +393,7 @@ struct MediaUploadPreviewScreen_Previews: PreviewProvider, TestablePreview {
|
||||
title: "App Icon.png",
|
||||
shouldShowCaptionWarning: true,
|
||||
galleryEnabled: true,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: .volatile()),
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
+1
-1
@@ -102,6 +102,6 @@ struct AnalyticsPromptScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
static func makeViewModel(showTerms: Bool = true) -> AnalyticsPromptScreenViewModel {
|
||||
AnalyticsPromptScreenViewModel(termsURL: showTerms ? AppSettings.volatile().analyticsTermsURL : nil)
|
||||
AnalyticsPromptScreenViewModel(termsURL: showTerms ? UserSettings.volatile().analyticsTermsURL : nil)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import SwiftUI
|
||||
|
||||
struct IdentityConfirmationScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: IdentityConfirmationScreenCoordinatorParameters) {
|
||||
viewModel = IdentityConfirmationScreenViewModel(userSession: parameters.userSession,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,11 +20,11 @@ class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelTy
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol, appSettings: AppSettings, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
init(userSession: UserSessionProtocol, userSettings: UserSettings, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSession = userSession
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: appSettings.deviceVerificationURL))
|
||||
super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: userSettings.deviceVerificationURL))
|
||||
|
||||
Task { [weak self] in
|
||||
for await state in userSession.sessionSecurityStatePublisher.values {
|
||||
|
||||
+1
-1
@@ -142,7 +142,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
userSession.sessionSecurityStatePublisher = CurrentValuePublisher<SessionSecurityState, Never>(.init(verificationState: .unverified, recoveryState: recoveryState))
|
||||
|
||||
return IdentityConfirmationScreenViewModel(userSession: userSession,
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ enum SessionVerificationScreenFlow {
|
||||
struct SessionVerificationScreenCoordinatorParameters {
|
||||
let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol
|
||||
let flow: SessionVerificationScreenFlow
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: SessionVerificationScreenCoordinatorParameters) {
|
||||
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy,
|
||||
flow: parameters.flow,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
mediaProvider: parameters.mediaProvider)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
|
||||
init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol,
|
||||
flow: SessionVerificationScreenFlow,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
verificationState: SessionVerificationScreenStateMachine.State = .initial) {
|
||||
self.sessionVerificationControllerProxy = sessionVerificationControllerProxy
|
||||
@@ -34,7 +34,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
stateMachine = SessionVerificationScreenStateMachine(state: verificationState)
|
||||
|
||||
super.init(initialViewState: .init(flow: flow,
|
||||
learnMoreURL: appSettings.encryptionURL,
|
||||
learnMoreURL: userSettings.encryptionURL,
|
||||
verificationState: verificationState),
|
||||
mediaProvider: mediaProvider)
|
||||
|
||||
|
||||
+1
-1
@@ -289,7 +289,7 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview {
|
||||
flow: SessionVerificationScreenFlow = .deviceInitiator) -> some View {
|
||||
let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(),
|
||||
flow: flow,
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
verificationState: state)
|
||||
|
||||
|
||||
+2
-3
@@ -15,7 +15,7 @@ struct PinnedEventsTimelineScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let emojiProvider: EmojiProviderProtocol
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
@@ -46,7 +46,7 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: PinnedEventsTimelineScreenCoordinatorParameters) {
|
||||
viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
analyticsService: parameters.analytics)
|
||||
timelineViewModel = TimelineViewModel(roomProxy: parameters.roomProxy,
|
||||
timelineController: parameters.timelineController,
|
||||
@@ -54,7 +54,6 @@ final class PinnedEventsTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
mediaPlayerProvider: parameters.mediaPlayerProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appMediator: parameters.appMediator,
|
||||
appSettings: parameters.appSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
emojiProvider: parameters.emojiProvider,
|
||||
linkMetadataProvider: parameters.linkMetadataProvider,
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ typealias PinnedEventsTimelineScreenViewModelType = StateStoreViewModel<PinnedEv
|
||||
class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelType, PinnedEventsTimelineScreenViewModelProtocol {
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<PinnedEventsTimelineScreenViewModelAction, Never> = .init()
|
||||
@@ -24,11 +24,11 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
analyticsService: AnalyticsServiceProtocol) {
|
||||
self.roomProxy = roomProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
self.analyticsService = analyticsService
|
||||
super.init(initialViewState: PinnedEventsTimelineScreenViewState())
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class PinnedEventsTimelineScreenViewModel: PinnedEventsTimelineScreenViewModelTy
|
||||
private func viewInRoomTimeline(eventID: String) async {
|
||||
switch await roomProxy.loadOrFetchEventDetails(for: eventID) {
|
||||
case .success(let event):
|
||||
let threadRootEventID: String? = if appSettings.threadsEnabled {
|
||||
let threadRootEventID: String? = if userSettings.threadsEnabled {
|
||||
event.threadRootEventId()
|
||||
} else {
|
||||
nil
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ struct PinnedEventsTimelineScreen: View {
|
||||
struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()))
|
||||
|
||||
static let emptyTimelineViewModel = makeTimelineViewModel(timelineItems: [])
|
||||
|
||||
@@ -46,7 +46,7 @@ struct QRCodeLoginScreenViewState: BindableState {
|
||||
var state: QRCodeLoginState
|
||||
let mode: QRCodeLoginScreenMode
|
||||
/// Whether or not it is possible for the screen to start the manual sign in flow. This was added to avoid
|
||||
/// having to handle server configuration when ``AppSettings.allowOtherAccountProviders`` is false.
|
||||
/// having to handle server configuration when ``UserSettings.allowOtherAccountProviders`` is false.
|
||||
let canSignInManually: Bool
|
||||
|
||||
let instructions = QRCodeLoginScreenInstructions()
|
||||
|
||||
@@ -177,7 +177,7 @@ struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return RoomDetailsEditScreenViewModel(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: .volatile()),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(userSettings: .volatile()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import SwiftUI
|
||||
struct RoomDetailsScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let userSession: UserSessionProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let appHooks: AppHooks
|
||||
let analyticsService: AnalyticsServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -54,7 +54,7 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
|
||||
isSpace = parameters.roomProxy.infoPublisher.value.isSpace
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
userSession: parameters.userSession,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
appHooks: parameters.appHooks,
|
||||
analyticsService: parameters.analyticsService,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
|
||||
@@ -45,7 +45,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
userSession: UserSessionProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
@@ -67,7 +67,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
|
||||
topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(),
|
||||
joinedMembersCount: roomProxy.infoPublisher.value.joinedMembersCount,
|
||||
notificationSettingsState: .loading,
|
||||
isNativeCallingEnabled: appSettings.nativeCallEnabled,
|
||||
isNativeCallingEnabled: userSettings.nativeCallEnabled,
|
||||
bindings: .init())
|
||||
super.init(initialViewState: appHooks.roomDetailsScreenHook.update(viewState),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
@@ -441,7 +441,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -470,7 +470,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
@@ -509,7 +509,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
|
||||
@@ -65,7 +65,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
completionSuggestionService: CompletionSuggestionServiceProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
mentionDisplayHelper: MentionDisplayHelper,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
composerDraftService: ComposerDraftServiceProtocol) {
|
||||
self.initialText = initialText
|
||||
@@ -80,7 +80,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
|
||||
super.init(initialViewState: ComposerToolbarViewState(wysiwygViewModel: wysiwygViewModel,
|
||||
isRoomEncrypted: roomProxy.infoPublisher.value.isEncrypted,
|
||||
isLocationSharingEnabled: appSettings.mapTilerConfiguration.publisher.value.isEnabled,
|
||||
isLocationSharingEnabled: userSettings.mapTilerConfiguration.publisher.value.isEnabled,
|
||||
bindings: .init()),
|
||||
mediaProvider: mediaProvider)
|
||||
|
||||
@@ -852,7 +852,7 @@ extension ComposerToolbarViewModel {
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
viewModel.state.bindings.composerFocused = focused
|
||||
|
||||
@@ -81,14 +81,14 @@ struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = makeViewModel()
|
||||
|
||||
static func makeViewModel() -> ComposerToolbarViewModel {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
return ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
wysiwygViewModel: WysiwygComposerViewModel(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
userSettings: userSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ struct RoomScreenCoordinatorParameters {
|
||||
let completionSuggestionService: CompletionSuggestionServiceProtocol
|
||||
let ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>
|
||||
let appMediator: AppMediatorProtocol
|
||||
let appSettings: AppSettings
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let composerDraftService: ComposerDraftServiceProtocol
|
||||
@@ -57,7 +56,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
private var roomViewModel: RoomScreenViewModelProtocol
|
||||
private var timelineViewModel: TimelineViewModelProtocol
|
||||
private var composerViewModel: ComposerToolbarViewModelProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
@@ -67,7 +66,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
init(parameters: RoomScreenCoordinatorParameters) {
|
||||
appSettings = parameters.appSettings
|
||||
userSettings = parameters.userSession.userSettings
|
||||
|
||||
var selectedPinnedEventID: String?
|
||||
if let focussedEvent = parameters.focussedEvent {
|
||||
@@ -78,7 +77,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
roomProxy: parameters.roomProxy,
|
||||
initialSelectedPinnedEventID: selectedPinnedEventID,
|
||||
ongoingCallRoomIDPublisher: parameters.ongoingCallRoomIDPublisher,
|
||||
appSettings: parameters.appSettings,
|
||||
appHooks: parameters.appHooks,
|
||||
analyticsService: parameters.analytics,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
@@ -90,7 +88,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
mediaPlayerProvider: parameters.mediaPlayerProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appMediator: parameters.appMediator,
|
||||
appSettings: parameters.appSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
emojiProvider: parameters.emojiProvider,
|
||||
linkMetadataProvider: parameters.linkMetadataProvider,
|
||||
@@ -106,7 +103,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
completionSuggestionService: parameters.completionSuggestionService,
|
||||
mediaProvider: parameters.userSession.mediaProvider,
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper(timelineContext: timelineViewModel.context),
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSession.userSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
composerDraftService: parameters.composerDraftService)
|
||||
self.composerViewModel = composerViewModel
|
||||
@@ -125,13 +122,13 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
case .displayReportContent(let itemID, let senderID):
|
||||
actionsSubject.send(.presentReportContent(itemID: itemID, senderID: senderID))
|
||||
case .displayCameraPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayMediaPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayDocumentPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayMediaPreview(let mediaPreviewViewModel):
|
||||
roomViewModel.displayMediaPreview(mediaPreviewViewModel)
|
||||
|
||||
@@ -17,7 +17,7 @@ typealias RoomScreenViewModelType = StateStoreViewModel<RoomScreenViewState, Roo
|
||||
class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol {
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -54,13 +54,12 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
roomProxy: JoinedRoomProxyProtocol,
|
||||
initialSelectedPinnedEventID: String?,
|
||||
ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>,
|
||||
appSettings: AppSettings,
|
||||
appHooks: AppHooks,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
clientProxy = userSession.clientProxy
|
||||
self.roomProxy = roomProxy
|
||||
self.appSettings = appSettings
|
||||
userSettings = userSession.userSettings
|
||||
self.analyticsService = analyticsService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
@@ -69,7 +68,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
let viewState = RoomScreenViewState(roomTitle: roomProxy.infoPublisher.value.displayNameOrID,
|
||||
roomAvatar: roomProxy.infoPublisher.value.avatar,
|
||||
isNativeCallingEnabled: appSettings.nativeCallEnabled,
|
||||
isNativeCallingEnabled: userSettings.nativeCallEnabled,
|
||||
hasOngoingCall: roomProxy.infoPublisher.value.hasRoomCall,
|
||||
isDM: roomProxy.infoPublisher.value.isDM,
|
||||
hasSuccessor: roomProxy.infoPublisher.value.successor != nil,
|
||||
@@ -128,7 +127,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
Task {
|
||||
// When navigating away from the room, we need to mark the room as both read
|
||||
// and fully read for Synapse to clear this room from the app's badge count.
|
||||
_ = await roomProxy.markAsRead(receiptType: appSettings.sharePresence ? .read : .readPrivate)
|
||||
_ = await roomProxy.markAsRead(receiptType: userSettings.sharePresence ? .read : .readPrivate)
|
||||
_ = await roomProxy.markAsRead(receiptType: .fullyRead)
|
||||
}
|
||||
// Work around QLPreviewController dismissal issues, see the InteractiveQuickLookModifier.
|
||||
@@ -167,11 +166,11 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
// MARK: - Private
|
||||
|
||||
private func setupSubscriptions(ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>) {
|
||||
appSettings.threadsEnabledPublisher
|
||||
userSettings.threadsEnabledPublisher
|
||||
.weakAssign(to: \.state.roomThreadListEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.liveLocationSharingSessionsByRoomIDPublisher
|
||||
userSettings.liveLocationSharingSessionsByRoomIDPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] sessionsByRoomID in
|
||||
guard let self else { return }
|
||||
@@ -265,10 +264,10 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
if let member = identityVerificationViolations.values.first {
|
||||
state.footerDetails = .verificationViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
learnMoreURL: userSettings.identityPinningViolationDetailsURL)
|
||||
} else if let member = identityPinningViolations.values.first {
|
||||
state.footerDetails = .pinViolation(member: member,
|
||||
learnMoreURL: appSettings.identityPinningViolationDetailsURL)
|
||||
learnMoreURL: userSettings.identityPinningViolationDetailsURL)
|
||||
} else {
|
||||
state.footerDetails = nil
|
||||
}
|
||||
@@ -429,7 +428,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
Task {
|
||||
switch await roomProxy.loadOrFetchEventDetails(for: eventID) {
|
||||
case .success(let event):
|
||||
if appSettings.threadsEnabled,
|
||||
if userSettings.threadsEnabled,
|
||||
let threadRootEventID = event.threadRootEventId() {
|
||||
actionsSubject.send(.focusEvent(eventID: threadRootEventID))
|
||||
actionsSubject.send(.displayThread(threadRootEventID: threadRootEventID, focussedEventID: eventID))
|
||||
@@ -466,7 +465,6 @@ extension RoomScreenViewModel {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: .volatile(),
|
||||
appHooks: appHooks,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
@@ -395,19 +395,19 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
powerLevelsConfiguration: .init(canUserSendMessage: canSendMessage)))
|
||||
let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.messageMultiSelectEnabled = isSelecting
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.messageMultiSelectEnabled = isSelecting
|
||||
let userSession = UserSessionMock(.init(userSettings: userSettings))
|
||||
|
||||
let timelineController = TimelineControllerMock(.init())
|
||||
let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: timelineController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ struct SearchScreenCoordinatorParameters {
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum SearchScreenCoordinatorAction {
|
||||
@@ -36,7 +36,7 @@ final class SearchScreenCoordinator: CoordinatorProtocol {
|
||||
clientProxy: parameters.clientProxy,
|
||||
mediaProvider: parameters.mediaProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appSettings: parameters.appSettings)
|
||||
userSettings: parameters.userSettings)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
@@ -19,7 +19,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let searchService: SearchServiceProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private var searchQueryObservationTask: Task<Void, Never>?
|
||||
private var searchModeObservationTask: Task<Void, Never>?
|
||||
private var loadingObservationTask: Task<Void, Never>?
|
||||
@@ -36,14 +36,14 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
clientProxy: ClientProxyProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
initialSearchQuery: String = "",
|
||||
initialSearchMode: SearchScreenMode = .rooms) {
|
||||
self.roomSummaryProvider = roomSummaryProvider
|
||||
self.clientProxy = clientProxy
|
||||
searchService = clientProxy.searchService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
|
||||
super.init(initialViewState: SearchScreenViewState(bindings: .init(searchQuery: initialSearchQuery, searchMode: initialSearchMode)),
|
||||
mediaProvider: mediaProvider)
|
||||
@@ -73,7 +73,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
.store(in: &cancellables)
|
||||
|
||||
// The room list is empty on a cold start, so the room breadcrumbs are re-resolved as it loads.
|
||||
appSettings.searchBreadcrumbsPublisher
|
||||
userSettings.searchBreadcrumbsPublisher
|
||||
.combineLatest(clientProxy.staticRoomSummaryProvider.roomListPublisher)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] storedBreadcrumbs, _ in
|
||||
@@ -118,7 +118,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
}
|
||||
|
||||
updateRooms(with: roomSummaryProvider.roomListPublisher.value)
|
||||
state.breadcrumbs = makeBreadcrumbs(from: appSettings.searchBreadcrumbs)
|
||||
state.breadcrumbs = makeBreadcrumbs(from: userSettings.searchBreadcrumbs)
|
||||
}
|
||||
|
||||
isolated deinit {
|
||||
@@ -215,13 +215,13 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
let searchQuery = state.bindings.searchQuery
|
||||
let newBreadcrumbs: [SearchBreadcrumb] = searchQuery.isEmpty ? [.room(roomID: roomID)] : [.query(searchQuery), .room(roomID: roomID)]
|
||||
|
||||
var breadcrumbs = appSettings.searchBreadcrumbs
|
||||
var breadcrumbs = userSettings.searchBreadcrumbs
|
||||
for breadcrumb in newBreadcrumbs {
|
||||
breadcrumbs.removeAll { $0 == breadcrumb }
|
||||
breadcrumbs.insert(breadcrumb, at: 0)
|
||||
}
|
||||
|
||||
appSettings.searchBreadcrumbs = Array(breadcrumbs.prefix(Self.maximumBreadcrumbCount))
|
||||
userSettings.searchBreadcrumbs = Array(breadcrumbs.prefix(Self.maximumBreadcrumbCount))
|
||||
}
|
||||
|
||||
private func setActiveTabLoading(_ isLoading: Bool) {
|
||||
|
||||
@@ -577,31 +577,31 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings.volatile())
|
||||
userSettings: UserSettings.volatile())
|
||||
static let noResultsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
initialSearchQuery: "John Doe")
|
||||
static let roomsViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms))),
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
initialSearchQuery: "Foundation")
|
||||
static let messagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(searchService: makeSearchService(results: .mockResults)),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
initialSearchQuery: "Foundation",
|
||||
initialSearchMode: .messages)
|
||||
static let loadingMessagesViewModel = SearchScreenViewModel(roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))),
|
||||
clientProxy: makeClientProxy(searchService: makeSearchService(paginationState: .loading)),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
initialSearchQuery: "Foundation",
|
||||
initialSearchMode: .messages)
|
||||
|
||||
@@ -609,11 +609,11 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: makeClientProxy(),
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: makeAppSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"),
|
||||
.query("Bob"),
|
||||
.room(roomID: "!room5:matrix.org"),
|
||||
.query("Element HR"),
|
||||
.query("Alice")]))
|
||||
userSettings: makeUserSettings(breadcrumbs: [.room(roomID: "!room1:matrix.org"),
|
||||
.query("Bob"),
|
||||
.room(roomID: "!room5:matrix.org"),
|
||||
.query("Element HR"),
|
||||
.query("Alice")]))
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
@@ -655,10 +655,10 @@ struct SearchScreen_Previews: PreviewProvider, TestablePreview {
|
||||
return mock
|
||||
}
|
||||
|
||||
private static func makeAppSettings(breadcrumbs: [SearchBreadcrumb]) -> AppSettings {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.searchBreadcrumbs = breadcrumbs
|
||||
return appSettings
|
||||
private static func makeUserSettings(breadcrumbs: [SearchBreadcrumb]) -> UserSettings {
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.searchBreadcrumbs = breadcrumbs
|
||||
return userSettings
|
||||
}
|
||||
|
||||
private static func makeClientProxy(searchService: SearchServiceProxyMock = makeSearchService()) -> ClientProxyMock {
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct SecureBackupScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
@@ -33,7 +33,7 @@ final class SecureBackupScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: SecureBackupScreenCoordinatorParameters) {
|
||||
viewModel = SecureBackupScreenViewModel(secureBackupController: parameters.clientProxy.secureBackupController,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
chatBackupDetailsURL: parameters.appSettings.chatBackupDetailsURL)
|
||||
chatBackupDetailsURL: parameters.userSettings.chatBackupDetailsURL)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ struct SecurityAndPrivacyScreenCoordinatorParameters {
|
||||
let roomProxy: JoinedRoomProxyProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let appSetting: AppSettings
|
||||
let appSetting: UserSettings
|
||||
}
|
||||
|
||||
enum SecurityAndPrivacyScreenCoordinatorAction {
|
||||
@@ -36,7 +36,7 @@ final class SecurityAndPrivacyScreenCoordinator: CoordinatorProtocol {
|
||||
viewModel = SecurityAndPrivacyScreenViewModel(roomProxy: parameters.roomProxy,
|
||||
clientProxy: parameters.clientProxy,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appSettings: parameters.appSetting)
|
||||
userSettings: parameters.appSetting)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
+7
-7
@@ -16,7 +16,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
|
||||
private let actionsSubject: PassthroughSubject<SecurityAndPrivacyScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<SecurityAndPrivacyScreenViewModelAction, Never> {
|
||||
@@ -26,18 +26,18 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
init(roomProxy: JoinedRoomProxyProtocol,
|
||||
clientProxy: ClientProxyProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appSettings: AppSettings) {
|
||||
userSettings: UserSettings) {
|
||||
self.roomProxy = roomProxy
|
||||
self.clientProxy = clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
|
||||
super.init(initialViewState: SecurityAndPrivacyScreenViewState(accessType: roomProxy.infoPublisher.value.joinRule.toSecurityAndPrivacyRoomAccessType,
|
||||
isEncryptionEnabled: roomProxy.infoPublisher.value.isEncrypted,
|
||||
historyVisibility: roomProxy.infoPublisher.value.historyVisibility.toSecurityAndPrivacyHistoryVisibility,
|
||||
isSpace: roomProxy.infoPublisher.value.isSpace,
|
||||
isKnockingEnabled: appSettings.knockingEnabled,
|
||||
historySharingDetailsURL: appSettings.historySharingDetailsURL))
|
||||
isKnockingEnabled: userSettings.knockingEnabled,
|
||||
historySharingDetailsURL: userSettings.historySharingDetailsURL))
|
||||
|
||||
if let powerLevels = roomProxy.infoPublisher.value.powerLevels {
|
||||
setupPermissions(powerLevels: powerLevels)
|
||||
@@ -151,7 +151,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
.weakAssign(to: \.state.isSpace, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.knockingEnabledPublisher
|
||||
userSettings.knockingEnabledPublisher
|
||||
.weakAssign(to: \.state.isKnockingEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
state.canEditAddress = powerLevels.canOwnUser(sendStateEvent: .roomCanonicalAlias)
|
||||
state.canEditJoinRule = powerLevels.canOwnUser(sendStateEvent: .roomJoinRules)
|
||||
state.canEditHistoryVisibility = powerLevels.canOwnUser(sendStateEvent: .roomHistoryVisibility)
|
||||
state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption) && !appSettings.forceDisableE2EE.publisher.value
|
||||
state.canEnableEncryption = powerLevels.canOwnUser(sendStateEvent: .roomEncryption) && !userSettings.forceDisableE2EE.publisher.value
|
||||
}
|
||||
|
||||
private func setupRoomDirectoryVisibility() {
|
||||
|
||||
+17
-17
@@ -233,7 +233,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
joinRule: .invite)),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: .volatile())
|
||||
userSettings: .volatile())
|
||||
|
||||
static let publicViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
canonicalAlias: "#room:matrix.org",
|
||||
@@ -242,17 +242,17 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: .volatile())
|
||||
userSettings: .volatile())
|
||||
|
||||
static let publicNoAddressViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
members: .allMembersAsCreator,
|
||||
joinRule: .public)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: .volatile())
|
||||
userSettings: .volatile())
|
||||
|
||||
static let singleSpaceMembersViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
let space = [SpaceServiceRoom].mockSingleRoom[0]
|
||||
|
||||
@@ -264,11 +264,11 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static let multipleSpacesMembersViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
|
||||
let spaces = [SpaceServiceRoom].mockJoinedSpaces
|
||||
|
||||
@@ -280,12 +280,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static let askToJoinViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.knockingEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.knockingEnabled = true
|
||||
|
||||
return SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isEncrypted: false,
|
||||
canonicalAlias: "#room:matrix.org",
|
||||
@@ -294,12 +294,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static let singleAskToJoinSpaceMembersViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.knockingEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.knockingEnabled = true
|
||||
|
||||
let space = [SpaceServiceRoom].mockSingleRoom[0]
|
||||
|
||||
@@ -311,12 +311,12 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static let multipleAskToJoinSpacesMembersViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.knockingEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.knockingEnabled = true
|
||||
|
||||
let spaces = [SpaceServiceRoom].mockJoinedSpaces
|
||||
|
||||
@@ -328,7 +328,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
userSettings: userSettings)
|
||||
}()
|
||||
|
||||
static let publicSpaceViewModel = SecurityAndPrivacyScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(isSpace: true,
|
||||
@@ -339,7 +339,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
isVisibleInPublicDirectory: true)),
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org")),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: .volatile())
|
||||
userSettings: .volatile())
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
+2
-2
@@ -27,11 +27,11 @@ class OAuthAccountSettingsPresenter: NSObject {
|
||||
init(accountURL: URL,
|
||||
presentationAnchor: UIWindow,
|
||||
appMediator: AppMediatorProtocol,
|
||||
appSettings: AppSettings,
|
||||
userSettings: UserSettings,
|
||||
appHooks: AppHooks,
|
||||
continuation: Continuation? = nil) {
|
||||
self.accountURL = accountURL
|
||||
redirectURL = appSettings.oAuthRedirectURL
|
||||
redirectURL = userSettings.oAuthRedirectURL
|
||||
self.presentationAnchor = presentationAnchor
|
||||
self.appMediator = appMediator
|
||||
self.appHooks = appHooks
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct AdvancedSettingsScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -20,7 +20,7 @@ final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private var viewModel: AdvancedSettingsScreenViewModelProtocol
|
||||
|
||||
init(parameters: AdvancedSettingsScreenCoordinatorParameters) {
|
||||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.appSettings,
|
||||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.userSettings.app,
|
||||
analytics: parameters.analytics,
|
||||
clientProxy: parameters.clientProxy,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, Adva
|
||||
override func process(viewAction: AdvancedSettingsScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .optimizeMediaUploadsChanged:
|
||||
// Note: Using a view action here as sinking the AppSettings publisher tracks the initial value.
|
||||
// Note: Using a view action here as sinking the UserSettings publisher tracks the initial value.
|
||||
analytics.trackInteraction(name: state.bindings.optimizeMediaUploads ? .MobileSettingsOptimizeMediaUploadsEnabled : .MobileSettingsOptimizeMediaUploadsDisabled)
|
||||
case let .updateHideInviteAvatars(value):
|
||||
hideInviteAvatarsTask = Task { [weak self] in await self?.updateHideInviteAvatars(value) }
|
||||
|
||||
+4
-7
@@ -160,13 +160,10 @@ private extension AppAppearance {
|
||||
// MARK: - Previews
|
||||
|
||||
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
return AdvancedSettingsScreenViewModel(advancedSettings: appSettings,
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}()
|
||||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: AppSettings.volatile(),
|
||||
analytics: AnalyticsServiceMock(.init()),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct AnalyticsSettingsScreenCoordinatorParameters {
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ final class AnalyticsSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: AnalyticsSettingsScreenViewModel
|
||||
|
||||
init(parameters: AnalyticsSettingsScreenCoordinatorParameters) {
|
||||
viewModel = AnalyticsSettingsScreenViewModel(appSettings: parameters.appSettings,
|
||||
viewModel = AnalyticsSettingsScreenViewModel(userSettings: parameters.userSettings,
|
||||
analytics: parameters.analytics)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -14,16 +14,16 @@ typealias AnalyticsSettingsScreenViewModelType = StateStoreViewModelV2<Analytics
|
||||
class AnalyticsSettingsScreenViewModel: AnalyticsSettingsScreenViewModelType, AnalyticsSettingsScreenViewModelProtocol {
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
|
||||
init(appSettings: AppSettings, analytics: AnalyticsServiceProtocol) {
|
||||
init(userSettings: UserSettings, analytics: AnalyticsServiceProtocol) {
|
||||
self.analytics = analytics
|
||||
|
||||
let strings = AnalyticsSettingsScreenStrings(termsURL: appSettings.analyticsTermsURL)
|
||||
let strings = AnalyticsSettingsScreenStrings(termsURL: userSettings.analyticsTermsURL)
|
||||
let bindings = AnalyticsSettingsScreenViewStateBindings(enableAnalytics: analytics.isEnabled)
|
||||
let state = AnalyticsSettingsScreenViewState(strings: strings, bindings: bindings)
|
||||
|
||||
super.init(initialViewState: state)
|
||||
|
||||
appSettings.analyticsConsentStatePublisher
|
||||
userSettings.analyticsConsentStatePublisher
|
||||
.map { $0 == .optedIn }
|
||||
.weakAssign(to: \.state.bindings.enableAnalytics, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ struct AnalyticsSettingsScreen: View {
|
||||
|
||||
struct AnalyticsSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
|
||||
let userSettings = UserSettings.volatile()
|
||||
let viewModel = AnalyticsSettingsScreenViewModel(userSettings: userSettings,
|
||||
analytics: AnalyticsServiceMock(.init()))
|
||||
AnalyticsSettingsScreen(context: viewModel.context)
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import SwiftUI
|
||||
final class LegalInformationScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: LegalInformationScreenViewModelProtocol
|
||||
|
||||
init(appSettings: AppSettings) {
|
||||
viewModel = LegalInformationScreenViewModel(appSettings: appSettings)
|
||||
init(userSettings: UserSettings) {
|
||||
viewModel = LegalInformationScreenViewModel(userSettings: userSettings)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
|
||||
+4
-4
@@ -12,9 +12,9 @@ import SwiftUI
|
||||
typealias LegalInformationScreenViewModelType = StateStoreViewModelV2<LegalInformationScreenViewState, LegalInformationScreenViewAction>
|
||||
|
||||
class LegalInformationScreenViewModel: LegalInformationScreenViewModelType, LegalInformationScreenViewModelProtocol {
|
||||
init(appSettings: AppSettings) {
|
||||
super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: appSettings.copyrightURL,
|
||||
acceptableUseURL: appSettings.acceptableUseURL,
|
||||
privacyURL: appSettings.privacyURL))
|
||||
init(userSettings: UserSettings) {
|
||||
super.init(initialViewState: LegalInformationScreenViewState(copyrightURL: userSettings.copyrightURL,
|
||||
acceptableUseURL: userSettings.acceptableUseURL,
|
||||
privacyURL: userSettings.privacyURL))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ struct LegalInformationScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct LegalInformationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = LegalInformationScreenViewModel(appSettings: .volatile())
|
||||
static let viewModel = LegalInformationScreenViewModel(userSettings: .volatile())
|
||||
static var previews: some View {
|
||||
LegalInformationScreen(context: viewModel.context)
|
||||
}
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ struct NotificationSettingsScreenCoordinatorParameters {
|
||||
let userNotificationCenter: UserNotificationCenterProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let isModallyPresented: Bool
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
}
|
||||
|
||||
enum NotificationSettingsScreenCoordinatorAction {
|
||||
@@ -39,9 +39,9 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = NotificationSettingsScreenViewModel(appSettings: parameters.appSettings,
|
||||
viewModel = NotificationSettingsScreenViewModel(userSettings: parameters.userSettings,
|
||||
userNotificationCenter: parameters.userNotificationCenter,
|
||||
notificationToneManager: NotificationToneManager(appSettings: parameters.appSettings),
|
||||
notificationToneManager: NotificationToneManager(userSettings: parameters.userSettings),
|
||||
notificationSettingsProxy: parameters.userSession.clientProxy.notificationSettings,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
|
||||
+12
-12
@@ -13,7 +13,7 @@ typealias NotificationSettingsScreenViewModelType = StateStoreViewModelV2<Notifi
|
||||
|
||||
class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelType, NotificationSettingsScreenViewModelProtocol {
|
||||
private var actionsSubject: PassthroughSubject<NotificationSettingsScreenViewModelAction, Never> = .init()
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let userNotificationCenter: UserNotificationCenterProtocol
|
||||
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -25,34 +25,34 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appSettings: AppSettings,
|
||||
init(userSettings: UserSettings,
|
||||
userNotificationCenter: UserNotificationCenterProtocol,
|
||||
notificationToneManager: NotificationToneManagerProtocol,
|
||||
notificationSettingsProxy: NotificationSettingsProxyProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
isModallyPresented: Bool) {
|
||||
self.appSettings = appSettings
|
||||
self.userSettings = userSettings
|
||||
self.userNotificationCenter = userNotificationCenter
|
||||
self.notificationSettingsProxy = notificationSettingsProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
notificationTonePreviewer = AudioPlayer()
|
||||
self.notificationToneManager = notificationToneManager
|
||||
|
||||
let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: appSettings.enableNotifications,
|
||||
showAllRoomListActivity: appSettings.showAllRoomListActivity)
|
||||
let bindings = NotificationSettingsScreenViewStateBindings(enableNotifications: userSettings.enableNotifications,
|
||||
showAllRoomListActivity: userSettings.showAllRoomListActivity)
|
||||
super.init(initialViewState: NotificationSettingsScreenViewState(bindings: bindings,
|
||||
isModallyPresented: isModallyPresented,
|
||||
selectedAlertTone: appSettings.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone,
|
||||
selectedAlertTone: userSettings.selectedNotificationTone ?? NotificationToneManager.defaultElementXMessageTone,
|
||||
availableCustomTones: notificationToneManager.customTones(),
|
||||
// macos lacks default sounds and its sandbox Sounds directory is immutable
|
||||
customToneSelectionEnabled: !ProcessInfo.processInfo.isiOSAppOnMac))
|
||||
|
||||
// Listen for changes to AppSettings.
|
||||
appSettings.enableNotificationsPublisher
|
||||
// Listen for changes to UserSettings.
|
||||
userSettings.enableNotificationsPublisher
|
||||
.weakAssign(to: \.state.bindings.enableNotifications, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.selectedNotificationTonePublisher
|
||||
userSettings.selectedNotificationTonePublisher
|
||||
.map { $0 ?? NotificationToneManager.defaultElementXMessageTone }
|
||||
.weakAssign(to: \.state.selectedAlertTone, on: self)
|
||||
.store(in: &cancellables)
|
||||
@@ -104,7 +104,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
}
|
||||
Task { await enableInvitations(state.bindings.invitationsEnabled) }
|
||||
case .showAllRoomListActivityChanged:
|
||||
appSettings.showAllRoomListActivity = state.bindings.showAllRoomListActivity
|
||||
userSettings.showAllRoomListActivity = state.bindings.showAllRoomListActivity
|
||||
case .close:
|
||||
actionsSubject.send(.close)
|
||||
case .fixConfigurationMismatchTapped:
|
||||
@@ -127,7 +127,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
}
|
||||
|
||||
func toggleNotifications() {
|
||||
appSettings.enableNotifications.toggle()
|
||||
userSettings.enableNotifications.toggle()
|
||||
}
|
||||
|
||||
private func setupDidBecomeActiveSubscription() {
|
||||
@@ -302,7 +302,7 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
try notificationToneManager.deleteCustomTone(tone)
|
||||
|
||||
if tone == state.selectedAlertTone {
|
||||
appSettings.selectedNotificationTone = nil
|
||||
userSettings.selectedNotificationTone = nil
|
||||
}
|
||||
} catch {
|
||||
MXLog.error("Error deleting alert tone \(tone.label): \(error)")
|
||||
|
||||
+4
-4
@@ -261,7 +261,7 @@ struct NotificationSettingsScreen: View {
|
||||
@available(iOS 26.0, *)
|
||||
struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel: NotificationSettingsScreenViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
let notificationCenter = UserNotificationCenterMock()
|
||||
notificationCenter.authorizationStatusReturnValue = .notDetermined
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
@@ -278,7 +278,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe"))))
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
var viewModel = NotificationSettingsScreenViewModel(userSettings: userSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationToneManager: NotificationToneManagerMock(.init()),
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
@@ -289,7 +289,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}()
|
||||
|
||||
static let viewModelConfigurationMismatch: NotificationSettingsScreenViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
let notificationCenter = UserNotificationCenterMock()
|
||||
notificationCenter.authorizationStatusReturnValue = .notDetermined
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
@@ -308,7 +308,7 @@ struct NotificationSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe"))))
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
var viewModel = NotificationSettingsScreenViewModel(userSettings: userSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationToneManager: NotificationToneManagerMock(.init()),
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
|
||||
@@ -11,7 +11,7 @@ import SwiftUI
|
||||
|
||||
struct SettingsScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let isBugReportServiceEnabled: Bool
|
||||
let isInSecondaryWindow: Bool
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
@@ -51,7 +51,7 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: SettingsScreenCoordinatorParameters) {
|
||||
viewModel = SettingsScreenViewModel(userSession: parameters.userSession,
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
isBugReportServiceEnabled: parameters.isBugReportServiceEnabled,
|
||||
isInSecondaryWindow: parameters.isInSecondaryWindow,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
|
||||
@@ -12,7 +12,7 @@ import SwiftUI
|
||||
typealias SettingsScreenViewModelType = StateStoreViewModelV2<SettingsScreenViewState, SettingsScreenViewAction>
|
||||
|
||||
class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewModelProtocol {
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -22,26 +22,26 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol, appSettings: AppSettings, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.appSettings = appSettings
|
||||
init(userSession: UserSessionProtocol, userSettings: UserSettings, isBugReportServiceEnabled: Bool, isInSecondaryWindow: Bool, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSettings = userSettings
|
||||
clientProxy = userSession.clientProxy
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
|
||||
userProfile: userSession.clientProxy.userProfilePublisher.value,
|
||||
showLinkNewDeviceButton: appSettings.linkNewDeviceEnabled,
|
||||
showLinkNewDeviceButton: userSettings.linkNewDeviceEnabled,
|
||||
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
|
||||
showDeveloperOptions: appSettings.developerOptionsEnabled,
|
||||
showAnalyticsSettings: appSettings.canPromptForAnalytics,
|
||||
showDeveloperOptions: userSettings.developerOptionsEnabled,
|
||||
showAnalyticsSettings: userSettings.canPromptForAnalytics,
|
||||
isBugReportServiceEnabled: isBugReportServiceEnabled,
|
||||
navigationBarVisibility: isInSecondaryWindow ? .hidden : .automatic),
|
||||
mediaProvider: userSession.mediaProvider)
|
||||
|
||||
appSettings.developerOptionsEnabledPublisher
|
||||
userSettings.developerOptionsEnabledPublisher
|
||||
.weakAssign(to: \.state.showDeveloperOptions, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.linkNewDeviceEnabledPublisher
|
||||
userSettings.linkNewDeviceEnabledPublisher
|
||||
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -138,7 +138,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
case .labs:
|
||||
actionsSubject.send(.labs)
|
||||
case .enableDeveloperOptions:
|
||||
appSettings.developerOptionsEnabled.toggle()
|
||||
userSettings.developerOptionsEnabled.toggle()
|
||||
case .developerOptions:
|
||||
actionsSubject.send(.developerOptions)
|
||||
case .deactivateAccount:
|
||||
|
||||
@@ -313,7 +313,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
displayName: "Alice Liddell",
|
||||
status: .mockFocussing))))
|
||||
return SettingsScreenViewModel(userSession: userSession,
|
||||
appSettings: .volatile(),
|
||||
userSettings: .volatile(),
|
||||
isBugReportServiceEnabled: isBugReportServiceEnabled,
|
||||
isInSecondaryWindow: false,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
||||
canChangeDisplayName: canChangeProfile))))
|
||||
|
||||
return UserDetailsEditScreenViewModel(userSession: userSession,
|
||||
mediaUploadingPreprocessor: .init(appSettings: .volatile()),
|
||||
mediaUploadingPreprocessor: .init(userSettings: .volatile()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
canonicalAlias: "#space:matrix.org",
|
||||
members: members)),
|
||||
userSession: UserSessionMock(.init()),
|
||||
appSettings: AppSettings.volatile(),
|
||||
userSettings: UserSettings.volatile(),
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
|
||||
@@ -154,7 +154,7 @@ struct StartChatScreen: View {
|
||||
|
||||
struct StartChatScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
let userSettings = UserSettings.volatile()
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com"))))
|
||||
let userDiscoveryService = UserDiscoveryServiceMock()
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice])
|
||||
|
||||
@@ -21,7 +21,7 @@ struct ThreadTimelineScreenCoordinatorParameters {
|
||||
let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
let completionSuggestionService: CompletionSuggestionServiceProtocol
|
||||
let appMediator: AppMediatorProtocol
|
||||
let appSettings: AppSettings
|
||||
let userSettings: UserSettings
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let composerDraftService: ComposerDraftServiceProtocol
|
||||
let timelineControllerFactory: TimelineControllerFactoryProtocol
|
||||
@@ -46,7 +46,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
private let viewModel: ThreadTimelineScreenViewModelProtocol
|
||||
private let timelineViewModel: TimelineViewModelProtocol
|
||||
private var composerViewModel: ComposerToolbarViewModelProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
@@ -56,7 +56,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
init(parameters: ThreadTimelineScreenCoordinatorParameters) {
|
||||
appSettings = parameters.appSettings
|
||||
userSettings = parameters.userSettings
|
||||
|
||||
viewModel = ThreadTimelineScreenViewModel(roomProxy: parameters.roomProxy, userSession: parameters.userSession)
|
||||
|
||||
@@ -67,7 +67,6 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
mediaPlayerProvider: parameters.mediaPlayerProvider,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
appMediator: parameters.appMediator,
|
||||
appSettings: parameters.appSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
emojiProvider: parameters.emojiProvider,
|
||||
linkMetadataProvider: parameters.linkMetadataProvider,
|
||||
@@ -84,7 +83,7 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
completionSuggestionService: parameters.completionSuggestionService,
|
||||
mediaProvider: parameters.userSession.mediaProvider,
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper(timelineContext: timelineViewModel.context),
|
||||
appSettings: parameters.appSettings,
|
||||
userSettings: parameters.userSettings,
|
||||
analyticsService: parameters.analytics,
|
||||
composerDraftService: parameters.composerDraftService)
|
||||
}
|
||||
@@ -110,13 +109,13 @@ final class ThreadTimelineScreenCoordinator: CoordinatorProtocol {
|
||||
case .displayReportContent(let itemID, let senderID):
|
||||
actionsSubject.send(.presentReportContent(itemID: itemID, senderID: senderID))
|
||||
case .displayCameraPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .camera, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayMediaPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .photoLibrary, selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayDocumentPicker:
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: appSettings.galleryEnabled)),
|
||||
actionsSubject.send(.presentMediaUploadPicker(mode: .init(source: .documents(), selectionType: .multiple(galleryEnabled: userSettings.galleryEnabled)),
|
||||
caption: composerViewModel.context.plainComposerText))
|
||||
case .displayMediaPreview(let mediaPreviewViewModel):
|
||||
viewModel.displayMediaPreview(mediaPreviewViewModel)
|
||||
|
||||
@@ -40,7 +40,7 @@ class TimelineInteractionHandler {
|
||||
private let voiceMessageRecorder: VoiceMessageRecorderProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appMediator: AppMediatorProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let emojiProvider: EmojiProviderProtocol
|
||||
private let linkMetadataProvider: LinkMetadataProviderProtocol
|
||||
@@ -78,7 +78,6 @@ class TimelineInteractionHandler {
|
||||
voiceMessageRecorder: VoiceMessageRecorderProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appMediator: AppMediatorProtocol,
|
||||
appSettings: AppSettings,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
emojiProvider: EmojiProviderProtocol,
|
||||
linkMetadataProvider: LinkMetadataProviderProtocol,
|
||||
@@ -90,7 +89,7 @@ class TimelineInteractionHandler {
|
||||
self.voiceMessageRecorder = voiceMessageRecorder
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appMediator = appMediator
|
||||
self.appSettings = appSettings
|
||||
userSettings = userSession.userSettings
|
||||
self.analyticsService = analyticsService
|
||||
self.emojiProvider = emojiProvider
|
||||
self.linkMetadataProvider = linkMetadataProvider
|
||||
@@ -456,8 +455,8 @@ class TimelineInteractionHandler {
|
||||
// MARK: Audio Playback
|
||||
|
||||
func changePlaybackSpeed(for itemID: TimelineItemIdentifier) {
|
||||
let nextSpeed = appSettings.voiceMessagePlaybackSpeed.next
|
||||
appSettings.voiceMessagePlaybackSpeed = nextSpeed
|
||||
let nextSpeed = userSettings.voiceMessagePlaybackSpeed.next
|
||||
userSettings.voiceMessagePlaybackSpeed = nextSpeed
|
||||
audioPlayerState(for: itemID)?.setPlaybackSpeed(nextSpeed)
|
||||
}
|
||||
|
||||
@@ -589,8 +588,8 @@ class TimelineInteractionHandler {
|
||||
title: L10n.commonVoiceMessage,
|
||||
duration: voiceMessageRoomTimelineItem.content.duration,
|
||||
waveform: voiceMessageRoomTimelineItem.content.waveform,
|
||||
playbackSpeed: appSettings.voiceMessagePlaybackSpeed,
|
||||
playbackSpeedPublisher: appSettings.voiceMessagePlaybackSpeedPublisher)
|
||||
playbackSpeed: userSettings.voiceMessagePlaybackSpeed,
|
||||
playbackSpeedPublisher: userSettings.voiceMessagePlaybackSpeedPublisher)
|
||||
mediaPlayerProvider.register(audioPlayerState: playerState)
|
||||
return playerState
|
||||
}
|
||||
@@ -711,7 +710,6 @@ class TimelineInteractionHandler {
|
||||
mediaPlayerProvider: mediaPlayerProvider,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analyticsService,
|
||||
emojiProvider: emojiProvider,
|
||||
linkMetadataProvider: linkMetadataProvider,
|
||||
|
||||
@@ -29,7 +29,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
private let mediaPlayerProvider: MediaPlayerProviderProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private let appMediator: AppMediatorProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let userSettings: UserSettings
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let emojiProvider: EmojiProviderProtocol
|
||||
|
||||
@@ -54,7 +54,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
mediaPlayerProvider: MediaPlayerProviderProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
appMediator: AppMediatorProtocol,
|
||||
appSettings: AppSettings,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
emojiProvider: EmojiProviderProtocol,
|
||||
linkMetadataProvider: LinkMetadataProviderProtocol,
|
||||
@@ -63,7 +62,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
self.timelineController = timelineController
|
||||
self.userSession = userSession
|
||||
self.mediaPlayerProvider = mediaPlayerProvider
|
||||
self.appSettings = appSettings
|
||||
userSettings = userSession.userSettings
|
||||
self.analyticsService = analyticsService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
self.appMediator = appMediator
|
||||
@@ -78,7 +77,6 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
voiceMessageRecorder: voiceMessageRecorder,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analyticsService,
|
||||
emojiProvider: emojiProvider,
|
||||
linkMetadataProvider: linkMetadataProvider,
|
||||
@@ -99,16 +97,16 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
timelineState: TimelineState(focussedEvent: focussedEventID.map { .init(eventID: $0, appearance: .immediate) }),
|
||||
ownUserID: roomProxy.ownUserID,
|
||||
hideTimelineMedia: hideTimelineMedia,
|
||||
isViewSourceEnabled: appSettings.viewSourceEnabled,
|
||||
areThreadsEnabled: appSettings.threadsEnabled,
|
||||
linkPreviewsEnabled: appSettings.linkPreviewsEnabled,
|
||||
jumpToReadMarkerEnabled: appSettings.jumpToReadMarkerEnabled,
|
||||
messageSelection: .init(isEnabled: appSettings.messageMultiSelectEnabled),
|
||||
isViewSourceEnabled: userSettings.viewSourceEnabled,
|
||||
areThreadsEnabled: userSettings.threadsEnabled,
|
||||
linkPreviewsEnabled: userSettings.linkPreviewsEnabled,
|
||||
jumpToReadMarkerEnabled: userSettings.jumpToReadMarkerEnabled,
|
||||
messageSelection: .init(isEnabled: userSettings.messageMultiSelectEnabled),
|
||||
hasPredecessor: roomProxy.predecessorRoom != nil,
|
||||
pinnedEventIDs: roomProxy.infoPublisher.value.pinnedEventIDs,
|
||||
emojiProvider: emojiProvider,
|
||||
linkMetadataProvider: hideTimelineMedia ? nil : linkMetadataProvider,
|
||||
mapTilerConfiguration: appSettings.mapTilerConfiguration.publisher.value,
|
||||
mapTilerConfiguration: userSettings.mapTilerConfiguration.publisher.value,
|
||||
bindings: .init(reactionsCollapsed: [:])),
|
||||
mediaProvider: userSession.mediaProvider,
|
||||
contentScannerService: userSession.contentScannerService)
|
||||
@@ -274,7 +272,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
case .voiceMessage(let voiceMessageAction):
|
||||
processVoiceMessageAction(voiceMessageAction)
|
||||
case .contentChanged(let isEmpty):
|
||||
guard appSettings.sharePresence else {
|
||||
guard userSettings.sharePresence else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -501,7 +499,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
setupAppSettingsSubscriptions()
|
||||
setupUserSettingsSubscriptions()
|
||||
|
||||
roomProxy.membersPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
@@ -510,7 +508,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
|
||||
roomProxy.typingMembersPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.filter { [weak self] _ in self?.appSettings.sharePresence ?? false }
|
||||
.filter { [weak self] _ in self?.userSettings.sharePresence ?? false }
|
||||
.weakAssign(to: \.state.typingMembers, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -562,7 +560,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
func viewInRoomTimeline(eventID: String) async {
|
||||
switch await roomProxy.loadOrFetchEventDetails(for: eventID) {
|
||||
case .success(let event):
|
||||
let threadRootEventID: String? = if appSettings.threadsEnabled {
|
||||
let threadRootEventID: String? = if userSettings.threadsEnabled {
|
||||
event.threadRootEventId()
|
||||
} else {
|
||||
nil
|
||||
@@ -573,20 +571,20 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func setupAppSettingsSubscriptions() {
|
||||
appSettings.sharePresencePublisher
|
||||
private func setupUserSettingsSubscriptions() {
|
||||
userSettings.sharePresencePublisher
|
||||
.weakAssign(to: \.state.showReadReceipts, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.viewSourceEnabledPublisher
|
||||
userSettings.viewSourceEnabledPublisher
|
||||
.weakAssign(to: \.state.isViewSourceEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.threadsEnabledPublisher
|
||||
userSettings.threadsEnabledPublisher
|
||||
.weakAssign(to: \.state.areThreadsEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
appSettings.jumpToReadMarkerEnabledPublisher
|
||||
userSettings.jumpToReadMarkerEnabledPublisher
|
||||
.weakAssign(to: \.state.jumpToReadMarkerEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -1148,7 +1146,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
|
||||
primaryButton: .init(title: L10n.actionOk, action: nil),
|
||||
secondaryButton: .init(title: L10n.actionLearnMore) { [weak self] in
|
||||
guard let self else { return }
|
||||
appMediator.open(appSettings.historySharingDetailsURL)
|
||||
appMediator.open(userSettings.historySharingDetailsURL)
|
||||
})
|
||||
case .inviteAgain:
|
||||
state.bindings.alertInfo = .init(id: .inviteAgain,
|
||||
@@ -1199,7 +1197,7 @@ extension TimelineViewModel {
|
||||
|
||||
extension TimelineViewModel {
|
||||
private func setupSelectionSubscriptions() {
|
||||
appSettings.messageMultiSelectEnabledPublisher
|
||||
userSettings.messageMultiSelectEnabledPublisher
|
||||
.sink { [weak self] isEnabled in
|
||||
self?.state.messageSelection.isEnabled = isEnabled
|
||||
if !isEnabled {
|
||||
@@ -1300,8 +1298,6 @@ extension TimelineViewModel {
|
||||
clientProxyMock.roomSummaryForIdentifierReturnValue = .mock(id: "!room:matrix.org", name: "Room", canonicalAlias: "#room:matrix.org")
|
||||
let roomProxy = JoinedRoomProxyMock(.init(name: "Preview room", predecessor: hasPredecessor ? .init(roomId: UUID().uuidString) : nil))
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxy,
|
||||
focussedEventID: nil,
|
||||
timelineController: timelineController ?? TimelineControllerMock(.init(timelineKind: timelineKind)),
|
||||
@@ -1309,9 +1305,8 @@ extension TimelineViewModel {
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview {
|
||||
isViewSourceEnabled: true,
|
||||
areThreadsEnabled: true,
|
||||
timelineKind: .live,
|
||||
emojiProvider: EmojiProvider(appSettings: .volatile()))
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()))
|
||||
guard let actions = provider.makeActions() else { return nil }
|
||||
|
||||
if var textItem = item as? TextRoomTimelineItem {
|
||||
|
||||
@@ -45,17 +45,14 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview {
|
||||
]
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members))
|
||||
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
@@ -421,39 +421,39 @@ private extension TimelineItemKeyForwarder {
|
||||
|
||||
struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel: TimelineViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.threadsEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.threadsEnabled = true
|
||||
let userSession = UserSessionMock(.init(userSettings: userSettings))
|
||||
|
||||
let roomProxy = JoinedRoomProxyMock(.init())
|
||||
return TimelineViewModel(roomProxy: roomProxy,
|
||||
focussedEventID: nil,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
static let viewModelWithPins: TimelineViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.threadsEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.threadsEnabled = true
|
||||
let userSession = UserSessionMock(.init(userSettings: userSettings))
|
||||
|
||||
let roomProxy = JoinedRoomProxyMock(.init(name: "Preview Room", pinnedEventIDs: ["pinned"]))
|
||||
return TimelineViewModel(roomProxy: roomProxy,
|
||||
focussedEventID: nil,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
@@ -461,19 +461,19 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
||||
static let unsafeViewModel = TimelineViewModel.mock(contentScannerService: ContentScannerServiceMock(.init(scanResult: false)))
|
||||
|
||||
static let selectingViewModel: TimelineViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
appSettings.messageMultiSelectEnabled = true
|
||||
let userSettings = UserSettings.volatile()
|
||||
userSettings.messageMultiSelectEnabled = true
|
||||
let userSession = UserSessionMock(.init(userSettings: userSettings))
|
||||
|
||||
let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
focussedEventID: nil,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
userSession: userSession,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(userSettings: userSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
viewModel.state.messageSelection.selectedEventIDs = ["selected"]
|
||||
|
||||
+10
-15
@@ -79,21 +79,16 @@ struct TimelineReadReceiptsView_Previews: PreviewProvider, TestablePreview {
|
||||
.mockMe
|
||||
]
|
||||
|
||||
static let viewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)),
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
static let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)),
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
static let singleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now")]
|
||||
static let doubleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now"),
|
||||
|
||||
+11
-16
@@ -89,22 +89,17 @@ struct HighlightedTimelineItemTimeline_Previews: PreviewProvider {
|
||||
static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
static let focussedEventID = "TimelineFixtures.default.5"
|
||||
static let composerViewModel = ComposerToolbarViewModel.mock()
|
||||
static let timelineViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
focussedEventID: focussedEventID,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
focussedEventID: focussedEventID,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
@@ -155,21 +155,16 @@ struct TimelineView_Previews: PreviewProvider { // Not testable as this preview
|
||||
name: "Preview room"))
|
||||
static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
static let composerViewModel = ComposerToolbarViewModel.mock()
|
||||
static let timelineViewModel = {
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
appSettings: appSettings,
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: TimelineControllerMock(.init()),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock(.init()),
|
||||
analyticsService: AnalyticsServiceMock(.init()),
|
||||
emojiProvider: EmojiProvider(userSettings: .volatile()),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
Reference in New Issue
Block a user