2018-09-03 20:54:03 +00:00
|
|
|
//
|
|
|
|
// NotificationsTableViewController.swift
|
|
|
|
// Tusker
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 9/2/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2018-09-11 14:52:21 +00:00
|
|
|
import Pachyderm
|
2022-11-28 02:54:58 +00:00
|
|
|
import Sentry
|
2018-09-03 20:54:03 +00:00
|
|
|
|
2022-09-13 01:52:10 +00:00
|
|
|
class NotificationsTableViewController: DiffableTimelineLikeTableViewController<NotificationsTableViewController.Section, NotificationsTableViewController.Item> {
|
2020-11-15 20:48:49 +00:00
|
|
|
|
2019-09-05 23:35:19 +00:00
|
|
|
private let statusCell = "statusCell"
|
|
|
|
private let actionGroupCell = "actionGroupCell"
|
|
|
|
private let followGroupCell = "followGroupCell"
|
2020-01-05 04:13:23 +00:00
|
|
|
private let followRequestCell = "followRequestCell"
|
2021-04-29 01:47:38 +00:00
|
|
|
private let pollCell = "pollCell"
|
2022-11-27 16:49:53 +00:00
|
|
|
private let updatedCell = "updatedCell"
|
2020-03-03 00:08:31 +00:00
|
|
|
private let unknownCell = "unknownCell"
|
2019-09-05 21:38:04 +00:00
|
|
|
|
2020-05-13 22:57:04 +00:00
|
|
|
weak var mastodonController: MastodonController!
|
2020-01-05 20:25:07 +00:00
|
|
|
|
2022-12-18 16:32:08 +00:00
|
|
|
private let allowedTypes: [Pachyderm.Notification.Kind]
|
2020-11-15 20:48:49 +00:00
|
|
|
private let groupTypes = [Pachyderm.Notification.Kind.favourite, .reblog, .follow]
|
2018-09-03 20:54:03 +00:00
|
|
|
|
2020-10-27 02:55:58 +00:00
|
|
|
private var newer: RequestRange?
|
|
|
|
private var older: RequestRange?
|
|
|
|
|
2020-01-05 20:25:07 +00:00
|
|
|
init(allowedTypes: [Pachyderm.Notification.Kind], mastodonController: MastodonController) {
|
2022-12-18 16:32:08 +00:00
|
|
|
self.allowedTypes = allowedTypes
|
2020-01-05 20:25:07 +00:00
|
|
|
self.mastodonController = mastodonController
|
2019-06-11 17:21:22 +00:00
|
|
|
|
2020-11-15 20:48:49 +00:00
|
|
|
super.init()
|
2020-12-14 23:44:41 +00:00
|
|
|
|
|
|
|
dragEnabled = true
|
2018-10-20 16:03:18 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 20:48:49 +00:00
|
|
|
required init?(coder: NSCoder) {
|
2018-10-20 16:03:18 +00:00
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
|
2020-11-15 20:48:49 +00:00
|
|
|
override class func refreshCommandTitle() -> String {
|
|
|
|
return NSLocalizedString("Refresh Notifications", comment: "refresh notifications command discoverability title")
|
|
|
|
}
|
|
|
|
|
2018-09-03 20:54:03 +00:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
2020-01-05 04:13:23 +00:00
|
|
|
tableView.register(UINib(nibName: "TimelineStatusTableViewCell", bundle: .main), forCellReuseIdentifier: statusCell)
|
|
|
|
tableView.register(UINib(nibName: "ActionNotificationGroupTableViewCell", bundle: .main), forCellReuseIdentifier: actionGroupCell)
|
|
|
|
tableView.register(UINib(nibName: "FollowNotificationGroupTableViewCell", bundle: .main), forCellReuseIdentifier: followGroupCell)
|
|
|
|
tableView.register(UINib(nibName: "FollowRequestNotificationTableViewCell", bundle: .main), forCellReuseIdentifier: followRequestCell)
|
2021-04-29 01:47:38 +00:00
|
|
|
tableView.register(UINib(nibName: "PollFinishedTableViewCell", bundle: .main), forCellReuseIdentifier: pollCell)
|
2022-11-27 16:49:53 +00:00
|
|
|
tableView.register(UINib(nibName: "StatusUpdatedNotificationTableViewCell", bundle: .main), forCellReuseIdentifier: updatedCell)
|
2020-03-03 03:31:37 +00:00
|
|
|
tableView.register(UINib(nibName: "BasicTableViewCell", bundle: .main), forCellReuseIdentifier: unknownCell)
|
2023-01-16 22:47:56 +00:00
|
|
|
|
2023-01-19 18:13:01 +00:00
|
|
|
tableView.cellLayoutMarginsFollowReadableWidth = UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac
|
2023-01-16 22:47:56 +00:00
|
|
|
tableView.allowsFocus = true
|
2023-01-18 00:32:50 +00:00
|
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
2020-06-15 23:39:44 +00:00
|
|
|
}
|
|
|
|
|
2023-01-18 00:32:50 +00:00
|
|
|
@objc private func handleStatusDeleted(_ notification: Foundation.Notification) {
|
|
|
|
guard let userInfo = notification.userInfo,
|
|
|
|
let accountID = mastodonController.accountInfo?.id,
|
|
|
|
userInfo["accountID"] as? String == accountID,
|
|
|
|
let statusIDs = userInfo["statusIDs"] as? [String] else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var snapshot = self.dataSource.snapshot()
|
|
|
|
// this is not efficient, since the number of notifications is almost certainly greater than the number of deleted statuses
|
|
|
|
// but we can't just check if the status is in the data source, since we don't have the corresponding notification/group
|
|
|
|
let toDelete = snapshot.itemIdentifiers
|
|
|
|
.filter { item in
|
|
|
|
guard case .notificationGroup(let group) = item else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return group.kind == .mention && statusIDs.contains(group.notifications.first!.status!.id)
|
|
|
|
}
|
|
|
|
if !toDelete.isEmpty {
|
|
|
|
snapshot.deleteItems(toDelete)
|
|
|
|
self.dataSource.apply(snapshot, animatingDifferences: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-22 19:41:56 +00:00
|
|
|
private func request(range: RequestRange) -> Request<[Pachyderm.Notification]> {
|
|
|
|
if mastodonController.instanceFeatures.notificationsAllowedTypes {
|
|
|
|
return Client.getNotifications(allowedTypes: allowedTypes, range: range)
|
|
|
|
} else {
|
|
|
|
var types = Set(Notification.Kind.allCases)
|
|
|
|
allowedTypes.forEach { types.remove($0) }
|
|
|
|
return Client.getNotifications(excludedTypes: Array(types), range: range)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-15 23:25:29 +00:00
|
|
|
// MARK: - DiffableTimelineLikeTableViewController
|
2018-09-03 20:54:03 +00:00
|
|
|
|
2022-09-13 01:52:10 +00:00
|
|
|
override func cellProvider(_ tableView: UITableView, _ indexPath: IndexPath, _ item: Item) -> UITableViewCell? {
|
|
|
|
if case .loadingIndicator = item {
|
|
|
|
return self.loadingIndicatorCell(indexPath: indexPath)
|
|
|
|
}
|
|
|
|
let group = item.group!
|
|
|
|
|
2019-09-05 21:38:04 +00:00
|
|
|
switch group.kind {
|
2023-01-25 01:43:43 +00:00
|
|
|
case .mention, .status:
|
2020-04-27 23:20:09 +00:00
|
|
|
guard let notification = group.notifications.first,
|
2019-11-19 17:08:11 +00:00
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: statusCell, for: indexPath) as? TimelineStatusTableViewCell else {
|
2019-09-05 21:38:04 +00:00
|
|
|
fatalError()
|
|
|
|
}
|
2018-09-03 20:54:03 +00:00
|
|
|
cell.delegate = self
|
2022-11-28 02:54:58 +00:00
|
|
|
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)
|
2023-01-25 01:43:43 +00:00
|
|
|
fatalError("missing status for \(group.kind) notification")
|
2022-11-28 02:54:58 +00:00
|
|
|
}
|
|
|
|
cell.updateUI(statusID: status.id, state: group.statusState!)
|
2018-09-03 20:54:03 +00:00
|
|
|
return cell
|
2019-09-05 21:38:04 +00:00
|
|
|
|
2018-09-03 20:54:03 +00:00
|
|
|
case .favourite, .reblog:
|
2019-09-05 21:38:04 +00:00
|
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: actionGroupCell, for: indexPath) as? ActionNotificationGroupTableViewCell else { fatalError() }
|
2018-09-03 20:54:03 +00:00
|
|
|
cell.delegate = self
|
2020-01-06 00:54:28 +00:00
|
|
|
cell.updateUI(group: group)
|
2018-09-03 20:54:03 +00:00
|
|
|
return cell
|
2019-09-05 21:38:04 +00:00
|
|
|
|
2018-09-03 20:54:03 +00:00
|
|
|
case .follow:
|
2020-01-05 04:13:23 +00:00
|
|
|
guard let cell = tableView.dequeueReusableCell(withIdentifier: followGroupCell, for: indexPath) as? FollowNotificationGroupTableViewCell else { fatalError() }
|
2018-09-03 20:54:03 +00:00
|
|
|
cell.delegate = self
|
2020-01-06 00:54:28 +00:00
|
|
|
cell.updateUI(group: group)
|
2018-09-03 20:54:03 +00:00
|
|
|
return cell
|
2020-01-05 04:13:23 +00:00
|
|
|
|
|
|
|
case .followRequest:
|
2020-04-27 23:20:09 +00:00
|
|
|
guard let notification = group.notifications.first,
|
2020-01-05 04:13:23 +00:00
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: followRequestCell, for: indexPath) as? FollowRequestNotificationTableViewCell else { fatalError() }
|
|
|
|
cell.delegate = self
|
2021-04-29 01:47:38 +00:00
|
|
|
cell.updateUI(notification: notification)
|
|
|
|
return cell
|
|
|
|
|
|
|
|
case .poll:
|
|
|
|
guard let notification = group.notifications.first,
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: pollCell, for: indexPath) as? PollFinishedTableViewCell else { fatalError() }
|
|
|
|
cell.delegate = self
|
2020-01-06 00:54:28 +00:00
|
|
|
cell.updateUI(notification: notification)
|
2020-01-05 04:13:23 +00:00
|
|
|
return cell
|
2020-03-03 00:08:31 +00:00
|
|
|
|
2022-11-27 16:49:53 +00:00
|
|
|
case .update:
|
|
|
|
guard let notification = group.notifications.first,
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: updatedCell, for: indexPath) as? StatusUpdatedNotificationTableViewCell else { fatalError() }
|
|
|
|
cell.delegate = self
|
|
|
|
cell.updateUI(notification: notification)
|
|
|
|
return cell
|
|
|
|
|
2020-03-03 00:08:31 +00:00
|
|
|
case .unknown:
|
2020-03-03 03:31:37 +00:00
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: unknownCell, for: indexPath)
|
|
|
|
cell.textLabel!.text = NSLocalizedString("Unknown Notification", comment: "unknown notification fallback cell text")
|
|
|
|
return cell
|
2018-09-03 20:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 02:54:58 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-15 23:25:29 +00:00
|
|
|
override func loadInitialItems(completion: @escaping (LoadResult) -> Void) {
|
2022-12-22 19:41:56 +00:00
|
|
|
mastodonController.run(request(range: .default)) { (response) in
|
2021-08-15 23:25:29 +00:00
|
|
|
switch response {
|
|
|
|
case let .failure(error):
|
|
|
|
completion(.failure(.client(error)))
|
|
|
|
|
2022-09-19 02:37:11 +00:00
|
|
|
case let .success(notifications, _):
|
2022-11-28 02:54:58 +00:00
|
|
|
self.validateNotifications(notifications)
|
2021-08-15 23:25:29 +00:00
|
|
|
let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes)
|
|
|
|
|
2022-06-08 22:02:48 +00:00
|
|
|
if !notifications.isEmpty {
|
2022-09-19 02:37:11 +00:00
|
|
|
self.newer = .after(id: notifications.first!.id, count: nil)
|
|
|
|
self.older = .before(id: notifications.last!.id, count: nil)
|
2022-06-08 22:02:48 +00:00
|
|
|
}
|
2021-08-15 23:25:29 +00:00
|
|
|
|
|
|
|
self.mastodonController.persistentContainer.addAll(notifications: notifications) {
|
|
|
|
var snapshot = Snapshot()
|
|
|
|
snapshot.appendSections([.notifications])
|
2022-09-13 01:52:10 +00:00
|
|
|
snapshot.appendItems(groups.map { .notificationGroup($0) }, toSection: .notifications)
|
2021-08-15 23:25:29 +00:00
|
|
|
completion(.success(snapshot))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override func loadOlderItems(currentSnapshot: @escaping () -> Snapshot, completion: @escaping (LoadResult) -> Void) {
|
|
|
|
guard let older = older else {
|
|
|
|
completion(.failure(.noOlder))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-22 19:41:56 +00:00
|
|
|
mastodonController.run(request(range: older)) { (response) in
|
2021-08-15 23:25:29 +00:00
|
|
|
switch response {
|
|
|
|
case let .failure(error):
|
|
|
|
completion(.failure(.client(error)))
|
|
|
|
|
2022-09-19 02:37:11 +00:00
|
|
|
case let .success(newNotifications, _):
|
2022-11-28 02:54:58 +00:00
|
|
|
self.validateNotifications(newNotifications)
|
2022-06-08 22:02:48 +00:00
|
|
|
if !newNotifications.isEmpty {
|
2022-09-19 02:37:11 +00:00
|
|
|
self.older = .before(id: newNotifications.last!.id, count: nil)
|
2021-08-15 23:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 02:57:46 +00:00
|
|
|
let olderGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
2021-08-15 23:25:29 +00:00
|
|
|
|
|
|
|
self.mastodonController.persistentContainer.addAll(notifications: newNotifications) {
|
2022-09-13 01:52:10 +00:00
|
|
|
let existingGroups = currentSnapshot().itemIdentifiers.compactMap(\.group)
|
2022-04-27 02:57:46 +00:00
|
|
|
let merged = NotificationGroup.mergeGroups(first: existingGroups, second: olderGroups, only: self.groupTypes)
|
2022-09-13 01:52:10 +00:00
|
|
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
2022-04-27 02:57:46 +00:00
|
|
|
snapshot.appendSections([.notifications])
|
2022-09-13 01:52:10 +00:00
|
|
|
snapshot.appendItems(merged.map { .notificationGroup($0) }, toSection: .notifications)
|
2021-08-15 23:25:29 +00:00
|
|
|
completion(.success(snapshot))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override func loadNewerItems(currentSnapshot: @escaping () -> Snapshot, completion: @escaping (LoadResult) -> Void) {
|
|
|
|
guard let newer = newer else {
|
|
|
|
completion(.failure(.noNewer))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-22 19:41:56 +00:00
|
|
|
mastodonController.run(request(range: newer)) { (response) in
|
2021-08-15 23:25:29 +00:00
|
|
|
switch response {
|
|
|
|
case let .failure(error):
|
|
|
|
completion(.failure(.client(error)))
|
|
|
|
|
2022-09-19 02:37:11 +00:00
|
|
|
case let .success(newNotifications, _):
|
2022-11-28 02:54:58 +00:00
|
|
|
self.validateNotifications(newNotifications)
|
2021-08-15 23:25:29 +00:00
|
|
|
guard !newNotifications.isEmpty else {
|
|
|
|
completion(.failure(.allCaughtUp))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-09-19 02:37:11 +00:00
|
|
|
self.newer = .after(id: newNotifications.first!.id, count: nil)
|
2021-08-15 23:25:29 +00:00
|
|
|
|
2022-04-27 02:57:46 +00:00
|
|
|
let newerGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
2021-08-15 23:25:29 +00:00
|
|
|
|
|
|
|
self.mastodonController.persistentContainer.addAll(notifications: newNotifications) {
|
2022-09-13 01:52:10 +00:00
|
|
|
let existingGroups = currentSnapshot().itemIdentifiers.compactMap(\.group)
|
2022-04-27 02:57:46 +00:00
|
|
|
let merged = NotificationGroup.mergeGroups(first: newerGroups, second: existingGroups, only: self.groupTypes)
|
2022-09-13 01:52:10 +00:00
|
|
|
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
2022-04-27 02:57:46 +00:00
|
|
|
snapshot.appendSections([.notifications])
|
2022-09-13 01:52:10 +00:00
|
|
|
snapshot.appendItems(merged.map { .notificationGroup($0) }, toSection: .notifications)
|
2021-08-15 23:25:29 +00:00
|
|
|
completion(.success(snapshot))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func dismissNotificationsInGroup(at indexPath: IndexPath, completion: (() -> Void)? = nil) {
|
2022-09-13 01:52:10 +00:00
|
|
|
guard let item = dataSource.itemIdentifier(for: indexPath),
|
|
|
|
let notifications = item.group?.notifications else {
|
|
|
|
return
|
|
|
|
}
|
2021-08-15 23:25:29 +00:00
|
|
|
let group = DispatchGroup()
|
2022-09-13 01:52:10 +00:00
|
|
|
notifications
|
2021-08-15 23:25:29 +00:00
|
|
|
.map { Pachyderm.Notification.dismiss(id: $0.id) }
|
|
|
|
.forEach { (request) in
|
|
|
|
group.enter()
|
|
|
|
mastodonController.run(request) { (_) in
|
|
|
|
group.leave()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
group.notify(queue: .main) {
|
|
|
|
var snapshot = self.dataSource.snapshot()
|
|
|
|
snapshot.deleteItems([item])
|
|
|
|
self.dataSource.apply(snapshot, completion: completion)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-15 20:48:49 +00:00
|
|
|
// MARK: - UITableViewDelegate
|
2018-09-15 17:01:13 +00:00
|
|
|
|
|
|
|
override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
2019-09-16 20:08:25 +00:00
|
|
|
let dismissAction = UIContextualAction(style: .destructive, title: NSLocalizedString("Dismiss", comment: "dismiss notification swipe action title")) { (action, view, completion) in
|
2019-11-17 23:49:48 +00:00
|
|
|
self.dismissNotificationsInGroup(at: indexPath) {
|
2019-09-16 20:08:25 +00:00
|
|
|
completion(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dismissAction.image = UIImage(systemName: "clear.fill")
|
2020-11-15 20:48:49 +00:00
|
|
|
|
2019-09-16 20:08:25 +00:00
|
|
|
let cellConfiguration = (tableView.cellForRow(at: indexPath) as? TableViewSwipeActionProvider)?.trailingSwipeActionsConfiguration()
|
2020-11-15 20:48:49 +00:00
|
|
|
|
2019-09-16 20:08:25 +00:00
|
|
|
let config: UISwipeActionsConfiguration
|
|
|
|
if let cellConfiguration = cellConfiguration {
|
2019-09-20 02:09:17 +00:00
|
|
|
config = UISwipeActionsConfiguration(actions: cellConfiguration.actions + [dismissAction])
|
|
|
|
config.performsFirstActionWithFullSwipe = cellConfiguration.performsFirstActionWithFullSwipe
|
2019-09-16 20:08:25 +00:00
|
|
|
} else {
|
|
|
|
config = UISwipeActionsConfiguration(actions: [dismissAction])
|
2019-09-20 02:09:17 +00:00
|
|
|
config.performsFirstActionWithFullSwipe = false
|
2019-09-16 20:08:25 +00:00
|
|
|
}
|
|
|
|
return config
|
2018-09-15 17:01:13 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 23:49:48 +00:00
|
|
|
override func getSuggestedContextMenuActions(tableView: UITableView, indexPath: IndexPath, point: CGPoint) -> [UIAction] {
|
|
|
|
return [
|
2020-11-15 20:48:49 +00:00
|
|
|
UIAction(title: "Dismiss Notification", image: UIImage(systemName: "clear.fill"), identifier: .init("dismissnotification"), handler: { (_) in
|
2019-11-17 23:49:48 +00:00
|
|
|
self.dismissNotificationsInGroup(at: indexPath)
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}
|
2020-11-15 20:48:49 +00:00
|
|
|
}
|
2018-09-03 20:54:03 +00:00
|
|
|
|
2021-08-15 23:25:29 +00:00
|
|
|
extension NotificationsTableViewController {
|
2022-09-13 01:52:10 +00:00
|
|
|
enum Section: DiffableTimelineLikeSection {
|
|
|
|
case loadingIndicator
|
2021-08-15 23:25:29 +00:00
|
|
|
case notifications
|
|
|
|
}
|
2022-09-13 01:52:10 +00:00
|
|
|
enum Item: DiffableTimelineLikeItem {
|
|
|
|
case loadingIndicator
|
|
|
|
case notificationGroup(NotificationGroup)
|
|
|
|
|
|
|
|
var group: NotificationGroup? {
|
|
|
|
switch self {
|
|
|
|
case .loadingIndicator:
|
|
|
|
return nil
|
|
|
|
case .notificationGroup(let group):
|
|
|
|
return group
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-15 23:25:29 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 20:48:49 +00:00
|
|
|
extension NotificationsTableViewController: TuskerNavigationDelegate {
|
2022-10-31 20:27:13 +00:00
|
|
|
var apiController: MastodonController! { mastodonController }
|
2018-09-03 20:54:03 +00:00
|
|
|
}
|
2018-09-03 22:46:20 +00:00
|
|
|
|
2022-05-02 03:04:56 +00:00
|
|
|
extension NotificationsTableViewController: MenuActionProvider {
|
|
|
|
}
|
|
|
|
|
2019-09-09 22:40:23 +00:00
|
|
|
extension NotificationsTableViewController: StatusTableViewCellDelegate {
|
2019-11-28 23:36:58 +00:00
|
|
|
func statusCellCollapsedStateChanged(_ cell: BaseStatusTableViewCell) {
|
2022-06-27 21:25:22 +00:00
|
|
|
if #available(iOS 16.0, *) {
|
|
|
|
} else {
|
|
|
|
cellHeightChanged()
|
|
|
|
}
|
2019-09-09 22:40:23 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-08 18:37:38 +00:00
|
|
|
|
|
|
|
extension NotificationsTableViewController: UITableViewDataSourcePrefetching {
|
|
|
|
func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
|
|
|
|
for indexPath in indexPaths {
|
2022-09-13 01:52:10 +00:00
|
|
|
guard let group = dataSource.itemIdentifier(for: indexPath)?.group else { continue }
|
2021-08-15 23:25:29 +00:00
|
|
|
for notification in group.notifications {
|
2022-02-17 03:12:47 +00:00
|
|
|
guard let avatar = notification.account.avatar else { continue }
|
|
|
|
ImageCache.avatars.fetchIfNotCached(avatar)
|
2019-09-05 21:38:04 +00:00
|
|
|
}
|
2019-02-08 18:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|