diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index 2336d99cc..96e7be38a 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -60,11 +60,7 @@ class MainTabBarController: UITabBarController { composeViewController = UIViewController() composeViewController.configureTabBarItem(with: .compose) - if BetaTestSettingsViewModel().testGroupedNotifications { - notificationViewController = NotificationListViewController() - } else { - notificationViewController = NotificationViewController() - } + notificationViewController = NotificationListViewController() notificationViewController.configureTabBarItem(with: .notifications) diff --git a/Mastodon/Scene/Settings/Beta Testing Settings/BetaTestSettingsViewController.swift b/Mastodon/Scene/Settings/Beta Testing Settings/BetaTestSettingsViewController.swift index ec58fe42f..d98cf4a24 100644 --- a/Mastodon/Scene/Settings/Beta Testing Settings/BetaTestSettingsViewController.swift +++ b/Mastodon/Scene/Settings/Beta Testing Settings/BetaTestSettingsViewController.swift @@ -5,19 +5,15 @@ import MastodonSDK struct BetaTestSettingsViewModel { let useStagingForDonations: Bool - let testGroupedNotifications: Bool init() { useStagingForDonations = UserDefaults.standard.useStagingForDonations - testGroupedNotifications = UserDefaults.standard.useGroupedNotifications } func byToggling(_ setting: BetaTestSetting) -> BetaTestSettingsViewModel { switch setting { case .useStagingForDonations: UserDefaults.standard.toggleUseStagingForDonations() - case .useGroupedNotifications: - UserDefaults.standard.toggleUseGroupedNotifications() case .clearPreviousDonationCampaigns: assertionFailure("this is an action, not a setting") break @@ -28,14 +24,11 @@ struct BetaTestSettingsViewModel { enum BetaTestSettingsSectionType: Hashable { case donations - case notifications var sectionTitle: String { switch self { case .donations: return "Donations" - case .notifications: - return "Notifications" } } } @@ -43,16 +36,13 @@ enum BetaTestSettingsSectionType: Hashable { enum BetaTestSetting: Hashable { case useStagingForDonations case clearPreviousDonationCampaigns - case useGroupedNotifications - + var labelText: String { switch self { case .useStagingForDonations: return "Donations use test endpoint" case .clearPreviousDonationCampaigns: return "Clear donation history" - case .useGroupedNotifications: - return "Test grouped notifications (WORK IN PROGRESS!)" } } } @@ -99,13 +89,6 @@ class BetaTestSettingsViewController: UIViewController { cell.textLabel?.text = itemIdentifier.labelText cell.textLabel?.textColor = .red return cell - case .useGroupedNotifications: - guard let selectionCell = tableView.dequeueReusableCell(withIdentifier: ToggleTableViewCell.reuseIdentifier, for: indexPath) as? ToggleTableViewCell else { assertionFailure("unexpected cell type"); return nil } - selectionCell.label.text = itemIdentifier.labelText - selectionCell.toggle.isOn = self.viewModel.testGroupedNotifications - selectionCell.toggle.removeTarget(self, action: nil, for: .valueChanged) - selectionCell.toggle.addTarget(self, action: #selector(didToggleGroupedNotifications), for: .valueChanged) - return selectionCell } }) @@ -129,21 +112,14 @@ class BetaTestSettingsViewController: UIViewController { @objc func didToggleDonationsStaging(_ sender: UISwitch) { viewModel = viewModel.byToggling(.useStagingForDonations) } - @objc func didToggleGroupedNotifications(_ sender: UISwitch) { - viewModel = viewModel.byToggling(.useGroupedNotifications) - let alert = UIAlertController(title: "Relaunch Required", message: "This change will not take effect until you relaunch the app.", preferredStyle: .alert) - alert.addAction(UIAlertAction(title: "OK", style: .default)) - present(alert, animated: true) - } func loadFromViewModel(animated: Bool = true) { var snapshot = NSDiffableDataSourceSnapshot() - snapshot.appendSections([.donations, .notifications]) + snapshot.appendSections([.donations]) snapshot.appendItems([.useStagingForDonations], toSection: .donations) if viewModel.useStagingForDonations { snapshot.appendItems([.useStagingForDonations, .clearPreviousDonationCampaigns], toSection: .donations) } - snapshot.appendItems([.useGroupedNotifications], toSection: .notifications) tableViewDataSource?.apply(snapshot, animatingDifferences: animated) } } @@ -152,7 +128,7 @@ extension BetaTestSettingsViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let identifier = tableViewDataSource?.itemIdentifier(for: indexPath) else { return } switch identifier { - case .useStagingForDonations, .useGroupedNotifications: + case .useStagingForDonations: break case .clearPreviousDonationCampaigns: Mastodon.Entity.DonationCampaign.forgetPreviousCampaigns() diff --git a/MastodonSDK/Sources/MastodonCommon/Preference/Preference+BetaTestSetting.swift b/MastodonSDK/Sources/MastodonCommon/Preference/Preference+BetaTestSetting.swift index 26b045943..fe7e6e329 100644 --- a/MastodonSDK/Sources/MastodonCommon/Preference/Preference+BetaTestSetting.swift +++ b/MastodonSDK/Sources/MastodonCommon/Preference/Preference+BetaTestSetting.swift @@ -27,22 +27,9 @@ extension UserDefaults { } set { self[#function] = newValue } } - - @objc public dynamic var useGroupedNotifications: Bool { - get { - register(defaults: [#function: true]) - return bool(forKey: #function) && UserDefaults.isDebugOrTestflightOrSimulator - } - set { self[#function] = newValue } - } public func toggleUseStagingForDonations() { let useStaging = UserDefaults.standard.useStagingForDonations UserDefaults.standard.useStagingForDonations = !useStaging } - - public func toggleUseGroupedNotifications() { - let useGrouped = UserDefaults.standard.useGroupedNotifications - UserDefaults.standard.useGroupedNotifications = !useGrouped - } } diff --git a/MastodonSDK/Sources/MastodonCore/DataController/MastodonFeedLoader.swift b/MastodonSDK/Sources/MastodonCore/DataController/MastodonFeedLoader.swift index 03bb33fa1..e7fbc1957 100644 --- a/MastodonSDK/Sources/MastodonCore/DataController/MastodonFeedLoader.swift +++ b/MastodonSDK/Sources/MastodonCore/DataController/MastodonFeedLoader.swift @@ -262,21 +262,11 @@ private extension MastodonFeedLoader { // MARK: - Notifications private extension MastodonFeedLoader { private func loadNotifications(withScope scope: APIService.MastodonNotificationScope, olderThan maxID: String? = nil) async throws -> [MastodonFeedItemIdentifier] { - let useGroupedNotifications = UserDefaults.standard.useGroupedNotifications - if useGroupedNotifications { - return try await _getGroupedNotifications(withScope: scope, olderThan: maxID) - } else { - return try await _getUngroupedNotifications(withScope: scope, olderThan: maxID) - } + return try await _getUngroupedNotifications(withScope: scope, olderThan: maxID) } private func loadNotifications(withAccountID accountID: String, olderThan maxID: String? = nil) async throws -> [MastodonFeedItemIdentifier] { - let useGroupedNotifications = false - if useGroupedNotifications { - return try await _getGroupedNotifications(accountID: accountID, olderThan: maxID) - } else { - return try await _getUngroupedNotifications(accountID: accountID, olderThan: maxID) - } + return try await _getUngroupedNotifications(accountID: accountID, olderThan: maxID) } private func _getUngroupedNotifications(withScope scope: APIService.MastodonNotificationScope? = nil, accountID: String? = nil, olderThan maxID: String? = nil) async throws -> [MastodonFeedItemIdentifier] {