diff --git a/Mastodon/In Progress New Layout and Datamodel/GroupedNotificationFeedLoader.swift b/Mastodon/In Progress New Layout and Datamodel/GroupedNotificationFeedLoader.swift index a394f6cfc..ee790adc1 100644 --- a/Mastodon/In Progress New Layout and Datamodel/GroupedNotificationFeedLoader.swift +++ b/Mastodon/In Progress New Layout and Datamodel/GroupedNotificationFeedLoader.swift @@ -53,7 +53,7 @@ final public class GroupedNotificationFeedLoader { private var isFetching: Bool = false - private let useGroupedNotificationsApi: Bool + public let useGroupedNotificationsApi: Bool private let cacheManager: (any NotificationsCacheManager)? private let user: MastodonUserIdentifier? diff --git a/Mastodon/In Progress New Layout and Datamodel/NotificationListViewController.swift b/Mastodon/In Progress New Layout and Datamodel/NotificationListViewController.swift index 154b564c6..b8669d943 100644 --- a/Mastodon/In Progress New Layout and Datamodel/NotificationListViewController.swift +++ b/Mastodon/In Progress New Layout and Datamodel/NotificationListViewController.swift @@ -41,6 +41,10 @@ class NotificationListViewController: UIHostingController "init(coder:) not implemented for NotificationListViewController") } + override func viewWillAppear(_ animated: Bool) { + viewModel.checkCanGroupNotifications() + } + @objc private func showNotificationPolicySettings(_ sender: Any) { guard let policy = viewModel.filteredNotificationsViewModel.policy else { return } Task { @@ -393,6 +397,16 @@ private class NotificationListViewModel: ObservableObject { break } } + + func checkCanGroupNotifications() { + guard let currentInstance = AuthenticationServiceProvider.shared.currentActiveUser.value?.authentication.instanceConfiguration else { + presentError?(APIService.APIError.implicit(.authenticationMissing)) + return + } + if currentInstance.canGroupNotifications, !feedLoader.useGroupedNotificationsApi { + createNewFeedLoader() + } + } private func createNewFeedLoader() { fetchFilteredNotificationsPolicy() diff --git a/MastodonSDK/Sources/MastodonCore/MastodonAuthentication.swift b/MastodonSDK/Sources/MastodonCore/MastodonAuthentication.swift index 02d9a6b3c..10ef680ba 100644 --- a/MastodonSDK/Sources/MastodonCore/MastodonAuthentication.swift +++ b/MastodonSDK/Sources/MastodonCore/MastodonAuthentication.swift @@ -44,7 +44,7 @@ public struct MastodonAuthentication: Codable, Hashable, UserIdentifier { public var canGroupNotifications: Bool { switch self { - case let .v1(instance): + case let .v1(_): return false case let .v2(instance, _): guard let apiVersion = instance.apiVersions?["mastodon"] else { return false }