mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Check for ability to group notifications before view appears
The instance information may not have been available when the initial check happened. See IOS-363 for root cause to fix later
This commit is contained in:
parent
1fc6e02320
commit
fc7f6bca0a
@ -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?
|
||||
|
@ -41,6 +41,10 @@ class NotificationListViewController: UIHostingController<NotificationListView>
|
||||
"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()
|
||||
|
@ -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 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user