Replace the UserPreference property wrapper with the new macro version.

This commit is contained in:
Doug
2026-06-26 13:46:14 +01:00
committed by Doug
parent c53e0c1466
commit f05fd41c36
17 changed files with 143 additions and 388 deletions
@@ -118,21 +118,21 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
.weakAssign(to: \.state.selectedRoomID, on: self)
.store(in: &cancellables)
appSettings.$roomListActivityVisibility
appSettings.roomListActivityVisibilityPublisher
.sink { [weak self] value in
self?.state.roomListActivityVisibility = value
self?.updateRooms()
}
.store(in: &cancellables)
appSettings.$seenInvites
appSettings.seenInvitesPublisher
.removeDuplicates()
.sink { [weak self] _ in
self?.updateRooms()
}
.store(in: &cancellables)
appSettings.$hasSeenNewSoundBanner
appSettings.hasSeenNewSoundBannerPublisher
.sink { [weak self] hasSeenNewSoundBanner in
self?.state.shouldShowNewSoundBanner = !hasSeenNewSoundBanner
}
@@ -173,7 +173,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
}
.store(in: &cancellables)
appSettings.$liveLocationSharingSessionsByRoomID
appSettings.liveLocationSharingSessionsByRoomIDPublisher
.map { [roomID = roomProxy.id] sessions in sessions[roomID] != nil }
.removeDuplicates()
.sink { [weak self] isSharingLiveLocationOnThisDevice in
@@ -163,11 +163,11 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
// MARK: - Private
private func setupSubscriptions(ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>) {
appSettings.$roomThreadListEnabled
appSettings.roomThreadListEnabledPublisher
.weakAssign(to: \.state.roomThreadListEnabled, on: self)
.store(in: &cancellables)
appSettings.$liveLocationSharingSessionsByRoomID
appSettings.liveLocationSharingSessionsByRoomIDPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] sessionsByRoomID in
guard let self else { return }
@@ -152,7 +152,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
.weakAssign(to: \.state.isSpace, on: self)
.store(in: &cancellables)
appSettings.$knockingEnabled
appSettings.knockingEnabledPublisher
.weakAssign(to: \.state.isKnockingEnabled, on: self)
.store(in: &cancellables)
}
@@ -23,7 +23,7 @@ class AnalyticsSettingsScreenViewModel: AnalyticsSettingsScreenViewModelType, An
super.init(initialViewState: state)
appSettings.$analyticsConsentState
appSettings.analyticsConsentStatePublisher
.map { $0 == .optedIn }
.weakAssign(to: \.state.bindings.enableAnalytics, on: self)
.store(in: &cancellables)
@@ -48,11 +48,11 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
customToneSelectionEnabled: !ProcessInfo.processInfo.isiOSAppOnMac))
// Listen for changes to AppSettings.
appSettings.$enableNotifications
appSettings.enableNotificationsPublisher
.weakAssign(to: \.state.bindings.enableNotifications, on: self)
.store(in: &cancellables)
appSettings.$selectedNotificationTone
appSettings.selectedNotificationTonePublisher
.map { $0 ?? NotificationToneManager.defaultElementXMessageTone }
.weakAssign(to: \.state.selectedAlertTone, on: self)
.store(in: &cancellables)
@@ -33,11 +33,11 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
navigationBarVisibility: isInSecondaryWindow ? .hidden : .automatic),
mediaProvider: userSession.mediaProvider)
appSettings.$developerOptionsEnabled
appSettings.developerOptionsEnabledPublisher
.weakAssign(to: \.state.showDeveloperOptions, on: self)
.store(in: &cancellables)
appSettings.$linkNewDeviceEnabled
appSettings.linkNewDeviceEnabledPublisher
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
.store(in: &cancellables)
@@ -508,7 +508,7 @@ class TimelineInteractionHandler {
duration: voiceMessageRoomTimelineItem.content.duration,
waveform: voiceMessageRoomTimelineItem.content.waveform,
playbackSpeed: appSettings.voiceMessagePlaybackSpeed,
playbackSpeedPublisher: appSettings.$voiceMessagePlaybackSpeed)
playbackSpeedPublisher: appSettings.voiceMessagePlaybackSpeedPublisher)
mediaPlayerProvider.register(audioPlayerState: playerState)
return playerState
}
@@ -556,19 +556,19 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
}
private func setupAppSettingsSubscriptions() {
appSettings.$sharePresence
appSettings.sharePresencePublisher
.weakAssign(to: \.state.showReadReceipts, on: self)
.store(in: &cancellables)
appSettings.$viewSourceEnabled
appSettings.viewSourceEnabledPublisher
.weakAssign(to: \.state.isViewSourceEnabled, on: self)
.store(in: &cancellables)
appSettings.$threadsEnabled
appSettings.threadsEnabledPublisher
.weakAssign(to: \.state.areThreadsEnabled, on: self)
.store(in: &cancellables)
appSettings.$jumpToReadMarkerEnabled
appSettings.jumpToReadMarkerEnabledPublisher
.weakAssign(to: \.state.jumpToReadMarkerEnabled, on: self)
.store(in: &cancellables)