Remove notification settings feature flag (#1693)

This commit is contained in:
Nicolas Mauri
2023-09-13 14:05:32 +02:00
committed by GitHub
parent f96969ac37
commit 8268ecc036
42 changed files with 88 additions and 145 deletions
@@ -37,7 +37,6 @@ final class AppSettings {
case userSuggestionsEnabled
case readReceiptsEnabled
case hasShownWelcomeScreen
case notificationSettingsEnabled
case swiftUITimelineEnabled
case richTextEditorEnabled
}
@@ -236,9 +235,6 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.readReceiptsEnabled, defaultValue: false, storageType: .userDefaults(store))
var readReceiptsEnabled
@UserPreference(key: UserDefaultsKeys.notificationSettingsEnabled, defaultValue: false, storageType: .userDefaults(store))
var notificationSettingsEnabled
@UserPreference(key: UserDefaultsKeys.swiftUITimelineEnabled, defaultValue: false, storageType: .volatile)
var swiftUITimelineEnabled
@@ -268,7 +268,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
private func buildRoom(with details: RoomSummaryDetails, invalidated: Bool) -> HomeScreenRoom {
let identifier = invalidated ? "invalidated-" + details.id : details.id
let notificationMode = details.notificationMode == .allMessages || appSettings.notificationSettingsEnabled == false ? nil : details.notificationMode
let notificationMode = details.notificationMode == .allMessages ? nil : details.notificationMode
return HomeScreenRoom(id: identifier,
roomId: details.id,
@@ -54,8 +54,7 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
roomProxy: parameters.roomProxy,
mediaProvider: parameters.mediaProvider,
userIndicatorController: parameters.userIndicatorController,
notificationSettingsProxy: parameters.notificationSettings,
appSettings: ServiceLocator.shared.settings)
notificationSettingsProxy: parameters.notificationSettings)
}
// MARK: - Public
@@ -48,7 +48,6 @@ struct RoomDetailsScreenViewState: BindableState {
var canEditRoomName = false
var canEditRoomTopic = false
var canEditRoomAvatar = false
let showNotificationSettings: Bool
var notificationSettingsState: RoomDetailsNotificationSettingsState = .loading
var canEdit: Bool {
@@ -64,10 +63,7 @@ struct RoomDetailsScreenViewState: BindableState {
var dmRecipient: RoomMemberDetails?
var shortcuts: [RoomDetailsScreenViewShortcut] {
var shortcuts: [RoomDetailsScreenViewShortcut] = []
if showNotificationSettings {
shortcuts.append(.mute)
}
var shortcuts: [RoomDetailsScreenViewShortcut] = [.mute]
if let permalink = dmRecipient?.permalink {
shortcuts.append(.share(link: permalink))
} else if let permalink {
@@ -38,8 +38,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
roomProxy: RoomProxyProtocol,
mediaProvider: MediaProviderProtocol,
userIndicatorController: UserIndicatorControllerProtocol,
notificationSettingsProxy: NotificationSettingsProxyProtocol,
appSettings: AppSettings) {
notificationSettingsProxy: NotificationSettingsProxyProtocol) {
self.accountUserID = accountUserID
self.roomProxy = roomProxy
self.mediaProvider = mediaProvider
@@ -55,7 +54,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
topic: roomProxy.topic,
avatarURL: roomProxy.avatarURL,
joinedMembersCount: roomProxy.joinedMembersCount,
showNotificationSettings: appSettings.notificationSettingsEnabled,
notificationSettingsState: .loading,
bindings: .init()),
imageProvider: mediaProvider)
@@ -32,9 +32,7 @@ struct RoomDetailsScreen: View {
topicSection
if context.viewState.showNotificationSettings {
notificationSection
}
notificationSection
if context.viewState.dmRecipient == nil {
aboutSection
@@ -277,14 +275,12 @@ struct RoomDetailsScreen_Previews: PreviewProvider {
notificationSettingsProxyMockConfiguration.roomMode.isDefault = false
let notificationSettingsProxy = NotificationSettingsProxyMock(with: notificationSettingsProxyMockConfiguration)
let appSettings = AppSettings()
appSettings.notificationSettingsEnabled = true
return RoomDetailsScreenViewModel(accountUserID: "@owner:somewhere.com",
roomProxy: roomProxy,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
appSettings: appSettings)
notificationSettingsProxy: notificationSettingsProxy)
}()
static let dmRoomViewModel = {
@@ -307,8 +303,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider {
roomProxy: roomProxy,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
appSettings: appSettings)
notificationSettingsProxy: notificationSettingsProxy)
}()
static let simpleRoomViewModel = {
@@ -328,8 +323,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider {
roomProxy: roomProxy,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
appSettings: appSettings)
notificationSettingsProxy: notificationSettingsProxy)
}()
static var previews: some View {
@@ -48,7 +48,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var shouldCollapseRoomStateEvents: Bool { get set }
var userSuggestionsEnabled: Bool { get set }
var readReceiptsEnabled: Bool { get set }
var notificationSettingsEnabled: Bool { get set }
var swiftUITimelineEnabled: Bool { get set }
var richTextEditorEnabled: Bool { get set }
}
@@ -47,13 +47,6 @@ struct DeveloperOptionsScreen: View {
}
}
Section("Notifications") {
Toggle(isOn: $context.notificationSettingsEnabled) {
Text("Show notification settings")
Text("Requires app reboot")
}
}
Section("Room creation") {
Toggle(isOn: $context.userSuggestionsEnabled) {
Text("User suggestions")
@@ -37,7 +37,6 @@ struct SettingsScreenViewState: BindableState {
var userAvatarURL: URL?
var userDisplayName: String?
var showSessionVerificationSection: Bool
var showNotificationSettings: Bool
var showDeveloperOptions: Bool
/// The presentation anchor used to display the OIDC account URL.
@@ -41,7 +41,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
userID: userSession.userID,
accountURL: userSession.clientProxy.accountURL,
showSessionVerificationSection: showSessionVerificationSection,
showNotificationSettings: appSettings.notificationSettingsEnabled,
showDeveloperOptions: appSettings.canShowDeveloperOptions),
imageProvider: userSession.mediaProvider)
@@ -52,11 +51,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
userSession.clientProxy.avatarURLPublisher
.weakAssign(to: \.state.userAvatarURL, on: self)
.store(in: &cancellables)
appSettings.$notificationSettingsEnabled
.weakAssign(to: \.state.showNotificationSettings, on: self)
.store(in: &cancellables)
Task {
await userSession.clientProxy.loadUserAvatarURL()
}
@@ -124,14 +124,12 @@ struct SettingsScreen: View {
}
// Notifications
if context.viewState.showNotificationSettings {
ListRow(label: .default(title: L10n.screenNotificationSettingsTitle,
systemIcon: .bell),
kind: .navigationLink {
context.send(viewAction: .notifications)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.notifications)
}
ListRow(label: .default(title: L10n.screenNotificationSettingsTitle,
systemIcon: .bell),
kind: .navigationLink {
context.send(viewAction: .notifications)
})
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.notifications)
// Analytics
ListRow(label: .default(title: L10n.commonAnalytics,
@@ -225,7 +223,6 @@ struct SettingsScreen_Previews: PreviewProvider {
deviceID: "AAAAAAAAAAA",
accountURL: "https://matrix.org/account"),
mediaProvider: MockMediaProvider())
ServiceLocator.shared.settings.notificationSettingsEnabled = true
return SettingsScreenViewModel(userSession: userSession,
appSettings: ServiceLocator.shared.settings)
}()
@@ -405,7 +405,6 @@ class ClientProxy: ClientProxyProtocol {
roomSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "AllRooms",
appSettings: appSettings,
notificationSettings: notificationSettings,
backgroundTaskService: backgroundTaskService)
try await roomSummaryProvider?.setRoomList(roomListService.allRooms())
@@ -413,7 +412,6 @@ class ClientProxy: ClientProxyProtocol {
inviteSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
eventStringBuilder: eventStringBuilder,
name: "Invites",
appSettings: appSettings,
notificationSettings: notificationSettings,
backgroundTaskService: backgroundTaskService)
try await inviteSummaryProvider?.setRoomList(roomListService.invites())
@@ -22,7 +22,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
private let roomListService: RoomListServiceProtocol
private let eventStringBuilder: RoomEventStringBuilder
private let name: String
private var appSettings: AppSettings
private let notificationSettings: NotificationSettingsProxyProtocol
private let backgroundTaskService: BackgroundTaskServiceProtocol
@@ -58,14 +57,12 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
init(roomListService: RoomListServiceProtocol,
eventStringBuilder: RoomEventStringBuilder,
name: String,
appSettings: AppSettings,
notificationSettings: NotificationSettingsProxyProtocol,
backgroundTaskService: BackgroundTaskServiceProtocol) {
self.roomListService = roomListService
serialDispatchQueue = DispatchQueue(label: "io.element.elementx.roomsummaryprovider", qos: .default)
self.eventStringBuilder = eventStringBuilder
self.name = name
self.appSettings = appSettings
self.notificationSettings = notificationSettings
self.backgroundTaskService = backgroundTaskService
@@ -74,9 +71,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
.sink { [weak self] in self?.updateRoomsWithDiffs($0) }
.store(in: &cancellables)
if appSettings.notificationSettingsEnabled {
setupNotificationSettingsSubscription()
}
setupNotificationSettingsSubscription()
}
func setRoomList(_ roomList: RoomList) {