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, _):
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
case .notification, .hashtag(_), .notificationBanner(_):
print("TODO")
// not supposed to happen
break
}
} // end Task
}

View File

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

View File

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

View File

@ -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<NotificationRequestsSection, NotificationRequestItem>()
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<NotificationRequestsSection, NotificationRequestItem>()
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)
}
}
}
}

View File

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

View File

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