forked from shadowfacts/Tusker
parent
23b76a7276
commit
a5506aeab6
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
|
import Sentry
|
||||||
|
|
||||||
class NotificationsTableViewController: DiffableTimelineLikeTableViewController<NotificationsTableViewController.Section, NotificationsTableViewController.Item> {
|
class NotificationsTableViewController: DiffableTimelineLikeTableViewController<NotificationsTableViewController.Section, NotificationsTableViewController.Item> {
|
||||||
|
|
||||||
|
@ -71,7 +72,18 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
fatalError()
|
fatalError()
|
||||||
}
|
}
|
||||||
cell.delegate = self
|
cell.delegate = self
|
||||||
cell.updateUI(statusID: notification.status!.id, state: group.statusState!)
|
guard let status = notification.status else {
|
||||||
|
let crumb = Breadcrumb(level: .fatal, category: "notifications")
|
||||||
|
crumb.data = [
|
||||||
|
"id": notification.id,
|
||||||
|
"type": notification.kind.rawValue,
|
||||||
|
"created_at": notification.createdAt.formatted(.iso8601),
|
||||||
|
"account": notification.account.id,
|
||||||
|
]
|
||||||
|
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||||
|
fatalError("missing status for mention notification")
|
||||||
|
}
|
||||||
|
cell.updateUI(statusID: status.id, state: group.statusState!)
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
case .favourite, .reblog:
|
case .favourite, .reblog:
|
||||||
|
@ -114,6 +126,19 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func validateNotifications(_ notifications: [Pachyderm.Notification]) {
|
||||||
|
for notif in notifications where notif.status == nil && (notif.kind == .mention || notif.kind == .reblog || notif.kind == .favourite) {
|
||||||
|
let crumb = Breadcrumb(level: .fatal, category: "notifications")
|
||||||
|
crumb.data = [
|
||||||
|
"id": notif.id,
|
||||||
|
"type": notif.kind.rawValue,
|
||||||
|
"created_at": notif.createdAt.formatted(.iso8601),
|
||||||
|
"account": notif.account.id,
|
||||||
|
]
|
||||||
|
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func loadInitialItems(completion: @escaping (LoadResult) -> Void) {
|
override func loadInitialItems(completion: @escaping (LoadResult) -> Void) {
|
||||||
let request = Client.getNotifications(excludeTypes: excludedTypes)
|
let request = Client.getNotifications(excludeTypes: excludedTypes)
|
||||||
mastodonController.run(request) { (response) in
|
mastodonController.run(request) { (response) in
|
||||||
|
@ -122,6 +147,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(notifications, _):
|
case let .success(notifications, _):
|
||||||
|
self.validateNotifications(notifications)
|
||||||
let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes)
|
let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes)
|
||||||
|
|
||||||
if !notifications.isEmpty {
|
if !notifications.isEmpty {
|
||||||
|
@ -152,6 +178,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(newNotifications, _):
|
case let .success(newNotifications, _):
|
||||||
|
self.validateNotifications(newNotifications)
|
||||||
if !newNotifications.isEmpty {
|
if !newNotifications.isEmpty {
|
||||||
self.older = .before(id: newNotifications.last!.id, count: nil)
|
self.older = .before(id: newNotifications.last!.id, count: nil)
|
||||||
}
|
}
|
||||||
|
@ -183,6 +210,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(newNotifications, _):
|
case let .success(newNotifications, _):
|
||||||
|
self.validateNotifications(newNotifications)
|
||||||
guard !newNotifications.isEmpty else {
|
guard !newNotifications.isEmpty else {
|
||||||
completion(.failure(.allCaughtUp))
|
completion(.failure(.allCaughtUp))
|
||||||
return
|
return
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import SwiftSoup
|
import SwiftSoup
|
||||||
|
import Sentry
|
||||||
|
|
||||||
class ActionNotificationGroupTableViewCell: UITableViewCell {
|
class ActionNotificationGroupTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
|
@ -66,7 +67,17 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
|
||||||
self.group = group
|
self.group = group
|
||||||
|
|
||||||
guard let firstNotification = group.notifications.first else { fatalError() }
|
guard let firstNotification = group.notifications.first else { fatalError() }
|
||||||
let status = firstNotification.status!
|
guard let status = firstNotification.status else {
|
||||||
|
let crumb = Breadcrumb(level: .fatal, category: "notifications")
|
||||||
|
crumb.data = [
|
||||||
|
"id": firstNotification.id,
|
||||||
|
"type": firstNotification.kind.rawValue,
|
||||||
|
"created_at": firstNotification.createdAt.formatted(.iso8601),
|
||||||
|
"account": firstNotification.account.id,
|
||||||
|
]
|
||||||
|
SentrySDK.addBreadcrumb(crumb: crumb)
|
||||||
|
fatalError("missing status for favorite/reblog notification")
|
||||||
|
}
|
||||||
self.statusID = status.id
|
self.statusID = status.id
|
||||||
|
|
||||||
updateUIForPreferences()
|
updateUIForPreferences()
|
||||||
|
|
Loading…
Reference in New Issue