Adress feedback (IOS-241)

This commit is contained in:
Nathan Mattes 2024-07-26 11:08:28 +02:00
parent 766e631217
commit bac8c23d2c
6 changed files with 29 additions and 30 deletions

View File

@ -515,7 +515,8 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
case .account(let account, _): case .account(let account, _):
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account) await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
case .notification, .hashtag(_), .notificationBanner(_): case .notification, .hashtag(_), .notificationBanner(_):
print("TODO") // not supposed to happen
break
} }
} // end Task } // end Task
} }

View File

@ -619,7 +619,8 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
account: account account: account
) )
case .notification, .hashtag(_), .notificationBanner(_): case .notification, .hashtag(_), .notificationBanner(_):
assertionFailure("TODO") // not supposed to happen
break
} }
} }
} }

View File

@ -63,7 +63,6 @@ class NotificationFilteringBannerTableViewCell: UITableViewCell {
private func setupConstraints() { private func setupConstraints() {
let constraints = [ let constraints = [
iconImageWrapperView.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width), iconImageWrapperView.widthAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.width),
iconImageWrapperView.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.defaultHigh), iconImageWrapperView.heightAnchor.constraint(equalToConstant: CGSize.authorAvatarButtonSize.height).priority(.defaultHigh),
iconImageView.centerXAnchor.constraint(equalTo: iconImageWrapperView.centerXAnchor), iconImageView.centerXAnchor.constraint(equalTo: iconImageWrapperView.centerXAnchor),

View File

@ -143,22 +143,20 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
if requests.count > 0 {
await MainActor.run { [weak self] in await MainActor.run { [weak self] in
guard let self else { return } guard let self else { return }
if requests.count > 0 {
self.viewModel.requests = requests self.viewModel.requests = requests
var snapshot = NSDiffableDataSourceSnapshot<NotificationRequestsSection, NotificationRequestItem>() var snapshot = NSDiffableDataSourceSnapshot<NotificationRequestsSection, NotificationRequestItem>()
snapshot.appendSections([.main]) snapshot.appendSections([.main])
snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } ) snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } )
self.dataSource?.apply(snapshot) self.dataSource?.apply(snapshot)
}
} else { } else {
await MainActor.run { [weak self] in _ = self.navigationController?.popViewController(animated: true)
_ = self?.navigationController?.popViewController(animated: true)
} }
} }
} }
func rejectNotificationRequest(_ cell: NotificationRequestTableViewCell, notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) { func rejectNotificationRequest(_ cell: NotificationRequestTableViewCell, notificationRequest: MastodonSDK.Mastodon.Entity.NotificationRequest) {
@ -192,22 +190,20 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
if requests.count > 0 {
await MainActor.run { [weak self] in await MainActor.run { [weak self] in
guard let self else { return } guard let self else { return }
if requests.count > 0 {
self.viewModel.requests = requests self.viewModel.requests = requests
var snapshot = NSDiffableDataSourceSnapshot<NotificationRequestsSection, NotificationRequestItem>() var snapshot = NSDiffableDataSourceSnapshot<NotificationRequestsSection, NotificationRequestItem>()
snapshot.appendSections([.main]) snapshot.appendSections([.main])
snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } ) snapshot.appendItems(self.viewModel.requests.compactMap { NotificationRequestItem.item($0) } )
self.dataSource?.apply(snapshot) self.dataSource?.apply(snapshot)
}
} else { } else {
await MainActor.run { [weak self] in _ = self.navigationController?.popViewController(animated: true)
_ = self?.navigationController?.popViewController(animated: true)
} }
} }
} }
} }

View File

@ -84,7 +84,7 @@ final class NotificationTimelineViewModel {
case .mentions: case .mentions:
FileManager.default.cacheNotificationsMentions(items: items, for: authContext.mastodonAuthenticationBox) FileManager.default.cacheNotificationsMentions(items: items, for: authContext.mastodonAuthenticationBox)
case .fromAccount(_): case .fromAccount(_):
//TODO: we don't persist these //NOTE: we don't persist these
break break
} }
}) })
@ -97,10 +97,12 @@ final class NotificationTimelineViewModel {
@objc func notificationFilteringChanged(_ notification: Notification) { @objc func notificationFilteringChanged(_ notification: Notification) {
Task { [weak self] in Task { [weak self] in
let policy = try await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox) guard let self else { return }
self?.notificationPolicy = policy.value
await self?.loadLatest() let policy = try await self.context.apiService.notificationPolicy(authenticationBox: self.authContext.mastodonAuthenticationBox)
self.notificationPolicy = policy.value
await self.loadLatest()
} }
} }
} }

View File

@ -56,7 +56,7 @@ extension PostQuery {
protocol PatchQuery: RequestQuery { } protocol PatchQuery: RequestQuery { }
extension PatchQuery { extension PatchQuery {
// By default a `PostQuery` does not have query items // By default a `PatchQuery` does not have query items
var queryItems: [URLQueryItem]? { nil } var queryItems: [URLQueryItem]? { nil }
} }