diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift index 5d23083b8..1290953f7 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift @@ -515,7 +515,8 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut case .account(let account, _): await DataSourceFacade.coordinateToProfileScene(provider: self, account: account) case .notification, .hashtag(_), .notificationBanner(_): - print("TODO") + // not supposed to happen + break } } // end Task } diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift index 24ad78b28..9db7ac73d 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift @@ -619,7 +619,8 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte account: account ) case .notification, .hashtag(_), .notificationBanner(_): - assertionFailure("TODO") + // not supposed to happen + break } } } diff --git a/Mastodon/Scene/Notification/Cell/NotificationFilteringBannerTableViewCell.swift b/Mastodon/Scene/Notification/Cell/NotificationFilteringBannerTableViewCell.swift index efa2874f9..2fd02878d 100644 --- a/Mastodon/Scene/Notification/Cell/NotificationFilteringBannerTableViewCell.swift +++ b/Mastodon/Scene/Notification/Cell/NotificationFilteringBannerTableViewCell.swift @@ -63,7 +63,6 @@ class NotificationFilteringBannerTableViewCell: UITableViewCell { private func setupConstraints() { let constraints = [ - iconImageWrapperView.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width), iconImageWrapperView.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.defaultHigh), iconImageView.centerXAnchor.constraint(equalTo: iconImageWrapperView.centerXAnchor), diff --git a/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift b/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift index ad0132f8d..8befab7c7 100644 --- a/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift +++ b/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift @@ -137,28 +137,26 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC private func acceptNotificationRequest(_ notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) async throws { _ = try await context.apiService.acceptNotificationRequests(authenticationBox: authContext.mastodonAuthenticationBox, - id: notificationRequest.id) + id: notificationRequest.id) let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) - if requests.count > 0 { - await MainActor.run { [weak self] in - guard let self else { return } + await MainActor.run { [weak self] in + guard let self else { return } + + if requests.count > 0 { self.viewModel.requests = requests var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } ) self.dataSource?.apply(snapshot) - } - } else { - await MainActor.run { [weak self] in - _ = self?.navigationController?.popViewController(animated: true) + } else { + _ = self.navigationController?.popViewController(animated: true) } } - } func rejectNotificationRequest(_ cell: NotificationRequestTableViewCell, notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) { @@ -183,31 +181,29 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC } } } - + private func rejectNotificationRequest(_ notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) async throws { _ = try await context.apiService.rejectNotificationRequests(authenticationBox: authContext.mastodonAuthenticationBox, id: notificationRequest.id) - + let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value - + NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) - - if requests.count > 0 { - await MainActor.run { [weak self] in - guard let self else { return } + + await MainActor.run { [weak self] in + guard let self else { return } + + if requests.count > 0 { self.viewModel.requests = requests var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } ) - + self.dataSource?.apply(snapshot) - } - } else { - await MainActor.run { [weak self] in - _ = self?.navigationController?.popViewController(animated: true) + } else { + _ = self.navigationController?.popViewController(animated: true) } } - } } diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift index 707cc2173..2f8d9a6b5 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift @@ -84,7 +84,7 @@ final class NotificationTimelineViewModel { case .mentions: FileManager.default.cacheNotificationsMentions(items: items, for: authContext.mastodonAuthenticationBox) case .fromAccount(_): - //TODO: we don't persist these + //NOTE: we don't persist these break } }) @@ -97,10 +97,12 @@ final class NotificationTimelineViewModel { @objc func notificationFilteringChanged(_ notification: Notification) { Task { [weak self] in - let policy = try await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox) - self?.notificationPolicy = policy.value + guard let self else { return } - await self?.loadLatest() + let policy = try await self.context.apiService.notificationPolicy(authenticationBox: self.authContext.mastodonAuthenticationBox) + self.notificationPolicy = policy.value + + await self.loadLatest() } } } diff --git a/MastodonSDK/Sources/MastodonSDK/Query/Query.swift b/MastodonSDK/Sources/MastodonSDK/Query/Query.swift index caaf6a02a..ba3ec63cd 100644 --- a/MastodonSDK/Sources/MastodonSDK/Query/Query.swift +++ b/MastodonSDK/Sources/MastodonSDK/Query/Query.swift @@ -56,7 +56,7 @@ extension PostQuery { protocol PatchQuery: RequestQuery { } extension PatchQuery { - // By default a `PostQuery` does not have query items + // By default a `PatchQuery` does not have query items var queryItems: [URLQueryItem]? { nil } }