2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Remove beta setting for grouped notifications

Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification
This commit is contained in:
shannon 2025-03-11 09:01:42 -04:00
parent dc6e0cfe2f
commit 357282ee53
4 changed files with 6 additions and 57 deletions

View File

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

View File

@ -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<BetaTestSettingsSectionType, BetaTestSetting>()
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()

View File

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

View File

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