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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 88 additions and 145 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -32,9 +32,7 @@ struct RoomDetailsScreen: View {
topicSection
if context.viewState.showNotificationSettings {
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 {

View File

@ -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 }
}

View File

@ -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")

View File

@ -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.

View File

@ -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)
@ -53,10 +52,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
.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()
}

View File

@ -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)
}
// 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)
}()

View File

@ -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())

View File

@ -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,10 +71,8 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
.sink { [weak self] in self?.updateRoomsWithDiffs($0) }
.store(in: &cancellables)
if appSettings.notificationSettingsEnabled {
setupNotificationSettingsSubscription()
}
}
func setRoomList(_ roomList: RoomList) {
guard listUpdatesTaskHandle == nil, stateUpdatesTaskHandle == nil else {

View File

@ -34,8 +34,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxyMock,
appSettings: AppSettings())
notificationSettingsProxy: notificationSettingsProxyMock)
AppSettings.reset()
}
@ -47,8 +46,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
let deferred = deferFulfillment(context.$viewState.collect(2).first())
context.send(viewAction: .processTapLeave)
let states = try await deferred.fulfill()
@ -65,8 +63,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
let deferred = deferFulfillment(context.$viewState.collect(2).first())
context.send(viewAction: .processTapLeave)
let states = try await deferred.fulfill()
@ -123,8 +120,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
await context.nextViewState()
XCTAssertEqual(context.viewState.dmRecipient, RoomMemberDetails(withProxy: recipient))
}
@ -141,8 +137,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
await context.nextViewState()
XCTAssertEqual(context.viewState.dmRecipient, RoomMemberDetails(withProxy: recipient))
@ -168,8 +163,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
await context.nextViewState()
XCTAssertEqual(context.viewState.dmRecipient, RoomMemberDetails(withProxy: recipient))
@ -196,8 +190,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
await context.nextViewState()
XCTAssertEqual(context.viewState.dmRecipient, RoomMemberDetails(withProxy: recipient))
@ -223,8 +216,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
await context.nextViewState()
XCTAssertEqual(context.viewState.dmRecipient, RoomMemberDetails(withProxy: recipient))
@ -250,8 +242,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -265,8 +256,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -295,8 +285,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -314,8 +303,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -333,8 +321,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -352,8 +339,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -370,8 +356,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
appSettings: AppSettings())
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()))
_ = await context.$viewState.debounce(for: .milliseconds(100), scheduler: DispatchQueue.main).values.first()
@ -386,8 +371,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxyMock,
appSettings: AppSettings())
notificationSettingsProxy: notificationSettingsProxyMock)
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState)
.filter(\.isError)
.first())