Compare commits
No commits in common. "a589bb2863f38ac77100a8729d513b49b34f26d2" and "b89df3f27ba30f5231d9e8e003e32183b25c92e7" have entirely different histories.
a589bb2863
...
b89df3f27b
|
@ -109,12 +109,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
kindStr = "📊 Poll finished"
|
||||
case .update:
|
||||
kindStr = "✏️ Edited"
|
||||
case .emojiReaction:
|
||||
if let emoji = notification.emoji {
|
||||
kindStr = "\(emoji) Reacted"
|
||||
} else {
|
||||
kindStr = nil
|
||||
}
|
||||
default:
|
||||
kindStr = nil
|
||||
}
|
||||
|
|
|
@ -213,10 +213,6 @@ public final class InstanceFeatures: ObservableObject {
|
|||
hasMastodonVersion(3, 1, 0)
|
||||
}
|
||||
|
||||
public var emojiReactionNotifications: Bool {
|
||||
instanceType.isPleroma
|
||||
}
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import WebURL
|
||||
|
||||
public struct Notification: Decodable, Sendable {
|
||||
public let id: String
|
||||
|
@ -15,10 +14,6 @@ public struct Notification: Decodable, Sendable {
|
|||
public let createdAt: Date
|
||||
public let account: Account
|
||||
public let status: Status?
|
||||
// Only present for pleroma emoji reactions
|
||||
// Either an emoji or :shortcode: (for akkoma custom emoji reactions)
|
||||
public let emoji: String?
|
||||
public let emojiURL: WebURL?
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
@ -32,8 +27,6 @@ public struct Notification: Decodable, Sendable {
|
|||
self.createdAt = try container.decode(Date.self, forKey: .createdAt)
|
||||
self.account = try container.decode(Account.self, forKey: .account)
|
||||
self.status = try container.decodeIfPresent(Status.self, forKey: .status)
|
||||
self.emoji = try container.decodeIfPresent(String.self, forKey: .emoji)
|
||||
self.emojiURL = try container.decodeIfPresent(WebURL.self, forKey: .emojiURL)
|
||||
}
|
||||
|
||||
public static func dismiss(id notificationID: String) -> Request<Empty> {
|
||||
|
@ -46,8 +39,6 @@ public struct Notification: Decodable, Sendable {
|
|||
case createdAt = "created_at"
|
||||
case account
|
||||
case status
|
||||
case emoji
|
||||
case emojiURL = "emoji_url"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +52,6 @@ extension Notification {
|
|||
case poll
|
||||
case update
|
||||
case status
|
||||
case emojiReaction = "pleroma:emoji_reaction"
|
||||
case unknown
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ public struct PushSubscription: Decodable, Sendable {
|
|||
"data[alerts][favourite]" => alerts.favourite,
|
||||
"data[alerts][poll]" => alerts.poll,
|
||||
"data[alerts][update]" => alerts.update,
|
||||
"data[alerts][pleroma:emoji_reaction]" => alerts.emojiReaction,
|
||||
"data[policy]" => policy.rawValue,
|
||||
]))
|
||||
}
|
||||
|
@ -59,7 +58,6 @@ public struct PushSubscription: Decodable, Sendable {
|
|||
"data[alerts][favourite]" => alerts.favourite,
|
||||
"data[alerts][poll]" => alerts.poll,
|
||||
"data[alerts][update]" => alerts.update,
|
||||
"data[alerts][pleroma:emoji_reaction]" => alerts.emojiReaction,
|
||||
"data[policy]" => policy.rawValue,
|
||||
]))
|
||||
}
|
||||
|
@ -87,19 +85,8 @@ extension PushSubscription {
|
|||
public let favourite: Bool
|
||||
public let poll: Bool
|
||||
public let update: Bool
|
||||
public let emojiReaction: Bool
|
||||
|
||||
public init(
|
||||
mention: Bool,
|
||||
status: Bool,
|
||||
reblog: Bool,
|
||||
follow: Bool,
|
||||
followRequest: Bool,
|
||||
favourite: Bool,
|
||||
poll: Bool,
|
||||
update: Bool,
|
||||
emojiReaction: Bool
|
||||
) {
|
||||
public init(mention: Bool, status: Bool, reblog: Bool, follow: Bool, followRequest: Bool, favourite: Bool, poll: Bool, update: Bool) {
|
||||
self.mention = mention
|
||||
self.status = status
|
||||
self.reblog = reblog
|
||||
|
@ -108,7 +95,6 @@ extension PushSubscription {
|
|||
self.favourite = favourite
|
||||
self.poll = poll
|
||||
self.update = update
|
||||
self.emojiReaction = emojiReaction
|
||||
}
|
||||
|
||||
public init(from decoder: any Decoder) throws {
|
||||
|
@ -124,8 +110,6 @@ extension PushSubscription {
|
|||
self.poll = try container.decode(Bool.self, forKey: PushSubscription.Alerts.CodingKeys.poll)
|
||||
// update added in mastodon 3.5.0
|
||||
self.update = try container.decodeIfPresent(Bool.self, forKey: PushSubscription.Alerts.CodingKeys.update) ?? false
|
||||
// pleroma/akkoma only
|
||||
self.emojiReaction = try container.decodeIfPresent(Bool.self, forKey: .emojiReaction) ?? false
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
|
@ -137,7 +121,6 @@ extension PushSubscription {
|
|||
case favourite
|
||||
case poll
|
||||
case update
|
||||
case emojiReaction = "pleroma:emoji_reaction"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,12 +124,6 @@ public final class Status: StatusProtocol, Decodable, Sendable {
|
|||
return request
|
||||
}
|
||||
|
||||
public static func getReactions(_ statusID: String, emoji: String, range: RequestRange = .default) -> Request<[Account]> {
|
||||
var request = Request<[Account]>(method: .get, path: "/api/v1/statuses/\(statusID)/reactions/\(emoji)")
|
||||
request.range = range
|
||||
return request
|
||||
}
|
||||
|
||||
public static func delete(_ statusID: String) -> Request<Empty> {
|
||||
return Request<Empty>(method: .delete, path: "/api/v1/statuses/\(statusID)")
|
||||
}
|
||||
|
|
|
@ -7,18 +7,17 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import WebURL
|
||||
|
||||
public struct NotificationGroup: Identifiable, Hashable, Sendable {
|
||||
public private(set) var notifications: [Notification]
|
||||
public let id: String
|
||||
public let kind: Kind
|
||||
public let kind: Notification.Kind
|
||||
|
||||
public init?(notifications: [Notification], kind: Kind) {
|
||||
public init?(notifications: [Notification]) {
|
||||
guard !notifications.isEmpty else { return nil }
|
||||
self.notifications = notifications
|
||||
self.id = notifications.first!.id
|
||||
self.kind = kind
|
||||
self.kind = notifications.first!.kind
|
||||
}
|
||||
|
||||
public static func ==(lhs: NotificationGroup, rhs: NotificationGroup) -> Bool {
|
||||
|
@ -45,61 +44,30 @@ public struct NotificationGroup: Identifiable, Hashable, Sendable {
|
|||
notifications.append(contentsOf: group.notifications)
|
||||
}
|
||||
|
||||
private static func groupKind(for notification: Notification) -> Kind {
|
||||
switch notification.kind {
|
||||
case .mention:
|
||||
return .mention
|
||||
case .reblog:
|
||||
return .reblog
|
||||
case .favourite:
|
||||
return .favourite
|
||||
case .follow:
|
||||
return .follow
|
||||
case .followRequest:
|
||||
return .followRequest
|
||||
case .poll:
|
||||
return .poll
|
||||
case .update:
|
||||
return .update
|
||||
case .status:
|
||||
return .status
|
||||
case .emojiReaction:
|
||||
if let emoji = notification.emoji {
|
||||
return .emojiReaction(emoji, notification.emojiURL)
|
||||
} else {
|
||||
return .unknown
|
||||
}
|
||||
case .unknown:
|
||||
return .unknown
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public static func createGroups(notifications: [Notification], only allowedTypes: [Notification.Kind]) -> [NotificationGroup] {
|
||||
var groups = [NotificationGroup]()
|
||||
for notification in notifications {
|
||||
let groupKind = groupKind(for: notification)
|
||||
|
||||
if allowedTypes.contains(notification.kind) {
|
||||
if let lastGroup = groups.last, canMerge(notification: notification, kind: groupKind, into: lastGroup) {
|
||||
if let lastGroup = groups.last, canMerge(notification: notification, into: lastGroup) {
|
||||
groups[groups.count - 1].append(notification)
|
||||
continue
|
||||
} else if groups.count >= 2 {
|
||||
let secondToLastGroup = groups[groups.count - 2]
|
||||
if allowedTypes.contains(notification.kind), canMerge(notification: notification, kind: groupKind, into: secondToLastGroup) {
|
||||
if allowedTypes.contains(groups[groups.count - 1].kind), canMerge(notification: notification, into: secondToLastGroup) {
|
||||
groups[groups.count - 2].append(notification)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
groups.append(NotificationGroup(notifications: [notification], kind: groupKind)!)
|
||||
groups.append(NotificationGroup(notifications: [notification])!)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
private static func canMerge(notification: Notification, kind: Kind, into group: NotificationGroup) -> Bool {
|
||||
return kind == group.kind && notification.status?.id == group.notifications.first!.status?.id
|
||||
private static func canMerge(notification: Notification, into group: NotificationGroup) -> Bool {
|
||||
return notification.kind == group.kind && notification.status?.id == group.notifications.first!.status?.id
|
||||
}
|
||||
|
||||
public static func mergeGroups(first: [NotificationGroup], second: [NotificationGroup], only allowedTypes: [Notification.Kind]) -> [NotificationGroup] {
|
||||
|
@ -114,21 +82,21 @@ public struct NotificationGroup: Identifiable, Hashable, Sendable {
|
|||
var second = second
|
||||
merged.reserveCapacity(second.count)
|
||||
while let firstGroupFromSecond = second.first,
|
||||
allowedTypes.contains(firstGroupFromSecond.kind.notificationKind) {
|
||||
allowedTypes.contains(firstGroupFromSecond.kind) {
|
||||
|
||||
second.removeFirst()
|
||||
|
||||
guard let lastGroup = merged.last,
|
||||
allowedTypes.contains(lastGroup.kind.notificationKind) else {
|
||||
allowedTypes.contains(lastGroup.kind) else {
|
||||
merged.append(firstGroupFromSecond)
|
||||
break
|
||||
}
|
||||
|
||||
if canMerge(notification: firstGroupFromSecond.notifications.first!, kind: firstGroupFromSecond.kind, into: lastGroup) {
|
||||
if canMerge(notification: firstGroupFromSecond.notifications.first!, into: lastGroup) {
|
||||
merged[merged.count - 1].append(group: firstGroupFromSecond)
|
||||
} else if merged.count >= 2 {
|
||||
let secondToLastGroup = merged[merged.count - 2]
|
||||
if allowedTypes.contains(secondToLastGroup.kind.notificationKind), canMerge(notification: firstGroupFromSecond.notifications.first!, kind: firstGroupFromSecond.kind, into: secondToLastGroup) {
|
||||
if allowedTypes.contains(secondToLastGroup.kind), canMerge(notification: firstGroupFromSecond.notifications.first!, into: secondToLastGroup) {
|
||||
merged[merged.count - 2].append(group: firstGroupFromSecond)
|
||||
} else {
|
||||
merged.append(firstGroupFromSecond)
|
||||
|
@ -141,42 +109,4 @@ public struct NotificationGroup: Identifiable, Hashable, Sendable {
|
|||
return merged
|
||||
}
|
||||
|
||||
public enum Kind: Sendable, Equatable {
|
||||
case mention
|
||||
case reblog
|
||||
case favourite
|
||||
case follow
|
||||
case followRequest
|
||||
case poll
|
||||
case update
|
||||
case status
|
||||
case emojiReaction(String, WebURL?)
|
||||
case unknown
|
||||
|
||||
var notificationKind: Notification.Kind {
|
||||
switch self {
|
||||
case .mention:
|
||||
.mention
|
||||
case .reblog:
|
||||
.reblog
|
||||
case .favourite:
|
||||
.favourite
|
||||
case .follow:
|
||||
.follow
|
||||
case .followRequest:
|
||||
.followRequest
|
||||
case .poll:
|
||||
.poll
|
||||
case .update:
|
||||
.update
|
||||
case .status:
|
||||
.status
|
||||
case .emojiReaction(_, _):
|
||||
.emojiReaction
|
||||
case .unknown:
|
||||
.unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ public struct PushSubscription {
|
|||
public static let favorite = Alerts(rawValue: 1 << 5)
|
||||
public static let poll = Alerts(rawValue: 1 << 6)
|
||||
public static let update = Alerts(rawValue: 1 << 7)
|
||||
public static let emojiReaction = Alerts(rawValue: 1 << 8)
|
||||
|
||||
public let rawValue: Int
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ private extension Pachyderm.PushSubscription.Alerts {
|
|||
followRequest: alerts.contains(.followRequest),
|
||||
favourite: alerts.contains(.favorite),
|
||||
poll: alerts.contains(.poll),
|
||||
update: alerts.contains(.update),
|
||||
emojiReaction: alerts.contains(.emojiReaction)
|
||||
update: alerts.contains(.update)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,13 +124,12 @@ class MastodonCachePersistentStore: NSPersistentCloudKitContainer {
|
|||
|
||||
// migrate saved data from local store to cloud store
|
||||
// this can be removed pre-app store release
|
||||
if !FileManager.default.fileExists(atPath: cloudStoreLocation.path) {
|
||||
var defaultPath = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
|
||||
defaultPath.appendPathComponent("\(accountInfo!.persistenceKey)_cache.sqlite", isDirectory: false)
|
||||
if FileManager.default.fileExists(atPath: defaultPath.path) {
|
||||
group.enter()
|
||||
var defaultPath = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
|
||||
defaultPath.appendPathComponent("\(accountInfo!.persistenceKey)_cache.sqlite", isDirectory: false)
|
||||
let defaultDesc = NSPersistentStoreDescription(url: defaultPath)
|
||||
defaultDesc.configuration = "Default"
|
||||
defaultDesc.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
||||
let defaultPSC = NSPersistentContainer(name: "\(accountInfo!.persistenceKey)_cache", managedObjectModel: MastodonCachePersistentStore.managedObjectModel)
|
||||
defaultPSC.persistentStoreDescriptions = [defaultDesc]
|
||||
defaultPSC.loadPersistentStores { _, error in
|
||||
|
|
|
@ -12,16 +12,7 @@ import HTMLStreamer
|
|||
|
||||
class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
||||
|
||||
private static func canDisplay(_ kind: NotificationGroup.Kind) -> Bool {
|
||||
switch kind {
|
||||
case .favourite, .reblog, .emojiReaction:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private let iconImageView = UIImageView().configure {
|
||||
private let iconView = UIImageView().configure {
|
||||
$0.tintColor = UIColor(red: 1, green: 204/255, blue: 0, alpha: 1)
|
||||
$0.contentMode = .scaleAspectFit
|
||||
NSLayoutConstraint.activate([
|
||||
|
@ -30,10 +21,6 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
])
|
||||
}
|
||||
|
||||
private let iconLabel = UILabel().configure {
|
||||
$0.font = .systemFont(ofSize: 30)
|
||||
}
|
||||
|
||||
private let avatarStack = UIStackView().configure {
|
||||
$0.axis = .horizontal
|
||||
$0.alignment = .fill
|
||||
|
@ -94,7 +81,6 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
private var group: NotificationGroup!
|
||||
private var statusID: String!
|
||||
|
||||
private var fetchCustomEmojiImage: (URL, Task<Void, Never>)?
|
||||
private var updateTimestampWorkItem: DispatchWorkItem?
|
||||
|
||||
deinit {
|
||||
|
@ -104,21 +90,15 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
iconImageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(iconImageView)
|
||||
iconLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(iconLabel)
|
||||
iconView.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(iconView)
|
||||
vStack.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(vStack)
|
||||
NSLayoutConstraint.activate([
|
||||
iconImageView.topAnchor.constraint(equalTo: vStack.topAnchor),
|
||||
iconImageView.trailingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16 + 50),
|
||||
iconLabel.topAnchor.constraint(equalTo: iconImageView.topAnchor),
|
||||
iconLabel.bottomAnchor.constraint(equalTo: iconImageView.bottomAnchor),
|
||||
iconLabel.leadingAnchor.constraint(equalTo: iconImageView.leadingAnchor),
|
||||
iconLabel.trailingAnchor.constraint(equalTo: iconImageView.trailingAnchor),
|
||||
iconView.topAnchor.constraint(equalTo: vStack.topAnchor),
|
||||
iconView.trailingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16 + 50),
|
||||
|
||||
vStack.leadingAnchor.constraint(equalTo: iconImageView.trailingAnchor, constant: 8),
|
||||
vStack.leadingAnchor.constraint(equalTo: iconView.trailingAnchor, constant: 8),
|
||||
vStack.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
|
||||
vStack.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
|
||||
vStack.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8),
|
||||
|
@ -136,7 +116,7 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
}
|
||||
|
||||
func updateUI(group: NotificationGroup) {
|
||||
guard ActionNotificationGroupCollectionViewCell.canDisplay(group.kind),
|
||||
guard group.kind == .favourite || group.kind == .reblog,
|
||||
let firstNotification = group.notifications.first,
|
||||
let status = firstNotification.status else {
|
||||
fatalError()
|
||||
|
@ -146,29 +126,9 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
|
||||
switch group.kind {
|
||||
case .favourite:
|
||||
iconImageView.image = UIImage(systemName: "star.fill")
|
||||
iconLabel.text = ""
|
||||
fetchCustomEmojiImage?.1.cancel()
|
||||
iconView.image = UIImage(systemName: "star.fill")
|
||||
case .reblog:
|
||||
iconImageView.image = UIImage(systemName: "repeat")
|
||||
iconLabel.text = ""
|
||||
fetchCustomEmojiImage?.1.cancel()
|
||||
case .emojiReaction(let emojiOrShortcode, let url):
|
||||
iconImageView.image = nil
|
||||
if let url = url.flatMap({ URL($0) }),
|
||||
fetchCustomEmojiImage?.0 != url {
|
||||
fetchCustomEmojiImage?.1.cancel()
|
||||
let task = Task {
|
||||
let (_, image) = await ImageCache.emojis.get(url)
|
||||
if !Task.isCancelled {
|
||||
self.iconImageView.image = image
|
||||
}
|
||||
}
|
||||
fetchCustomEmojiImage = (url, task)
|
||||
} else {
|
||||
iconLabel.text = emojiOrShortcode
|
||||
fetchCustomEmojiImage?.1.cancel()
|
||||
}
|
||||
iconView.image = UIImage(systemName: "repeat")
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
|
@ -247,8 +207,6 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
verb = "Favorited"
|
||||
case .reblog:
|
||||
verb = "Reblogged"
|
||||
case .emojiReaction(_, _):
|
||||
verb = "Reacted to"
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
|
@ -294,8 +252,6 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
|||
str += "Favorited by "
|
||||
case .reblog:
|
||||
str += "Reblogged by "
|
||||
case .emojiReaction(let emoji, _):
|
||||
str += "Reacted \(emoji) by "
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -75,17 +75,6 @@ class NotificationLoadingViewController: UIViewController {
|
|||
}
|
||||
let actionType = notification.kind == .reblog ? StatusActionAccountListViewController.ActionType.reblog : .favorite
|
||||
vc = StatusActionAccountListViewController(actionType: actionType, statusID: statusID, statusState: .unknown, accountIDs: [notification.account.id], mastodonController: mastodonController)
|
||||
case .emojiReaction:
|
||||
guard let statusID = notification.status?.id else {
|
||||
showLoadingError(Error.missingStatus)
|
||||
return
|
||||
}
|
||||
guard let emoji = notification.emoji else {
|
||||
showLoadingError(Error.unknownType)
|
||||
return
|
||||
}
|
||||
let actionType = StatusActionAccountListViewController.ActionType.emojiReaction(emoji, notification.emojiURL)
|
||||
vc = StatusActionAccountListViewController(actionType: actionType, statusID: statusID, statusState: .unknown, accountIDs: [notification.account.id], mastodonController: mastodonController)
|
||||
case .follow:
|
||||
vc = ProfileViewController(accountID: notification.account.id, mastodonController: mastodonController)
|
||||
case .followRequest:
|
||||
|
|
|
@ -178,7 +178,7 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
|
|||
case .hide:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: zeroHeightCell, for: indexPath, item: ())
|
||||
}
|
||||
case .favourite, .reblog, .emojiReaction:
|
||||
case .favourite, .reblog:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: actionGroupCell, for: indexPath, item: group)
|
||||
case .follow:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: followCell, for: indexPath, item: group)
|
||||
|
@ -317,7 +317,7 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
|
|||
snapshot.deleteItems([.group(group, collapseState, filterState)])
|
||||
} else if !dismissFailedIndices.isEmpty && dismissFailedIndices.count == notifications.count {
|
||||
let dismissFailed = dismissFailedIndices.sorted().map { notifications[$0] }
|
||||
snapshot.insertItems([.group(NotificationGroup(notifications: dismissFailed, kind: group.kind)!, collapseState, filterState)], afterItem: .group(group, collapseState, filterState))
|
||||
snapshot.insertItems([.group(NotificationGroup(notifications: dismissFailed)!, collapseState, filterState)], afterItem: .group(group, collapseState, filterState))
|
||||
snapshot.deleteItems([.group(group, collapseState, filterState)])
|
||||
}
|
||||
await apply(snapshot, animatingDifferences: true)
|
||||
|
@ -624,8 +624,8 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
|||
let state = collapseState?.copy() ?? .unknown
|
||||
selected(status: statusID, state: state)
|
||||
}
|
||||
case .favourite, .reblog, .emojiReaction(_, _):
|
||||
let type = StatusActionAccountListViewController.ActionType(group.kind)!
|
||||
case .favourite, .reblog:
|
||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||
let statusID = group.notifications.first!.status!.id
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
let vc = StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
|
||||
|
@ -666,9 +666,9 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
|||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForStatus(status, source: .view(cell), includeStatusButtonActions: group.kind == .poll || group.kind == .update))
|
||||
}
|
||||
case .favourite, .reblog, .emojiReaction(_, _):
|
||||
case .favourite, .reblog:
|
||||
return UIContextMenuConfiguration(previewProvider: {
|
||||
let type = StatusActionAccountListViewController.ActionType(group.kind)!
|
||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||
let statusID = group.notifications.first!.status!.id
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
return StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
|
||||
|
@ -751,7 +751,7 @@ extension NotificationsCollectionViewController: UICollectionViewDragDelegate {
|
|||
activity.displaysAuxiliaryScene = true
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
case .favourite, .reblog, .emojiReaction(_, _):
|
||||
case .favourite, .reblog:
|
||||
return []
|
||||
case .follow, .followRequest:
|
||||
guard group.notifications.count == 1 else {
|
||||
|
|
|
@ -74,9 +74,6 @@ private struct PushSubscriptionSettingsView: View {
|
|||
if mastodonController.instanceFeatures.pushNotificationTypeUpdate {
|
||||
toggle("Edits", alert: .update)
|
||||
}
|
||||
if mastodonController.instanceFeatures.emojiReactionNotifications {
|
||||
toggle("Reactions", alert: .emojiReaction)
|
||||
}
|
||||
// status notifications not supported until we can enable/disable them in the app
|
||||
}
|
||||
}
|
||||
|
@ -84,17 +81,14 @@ private struct PushSubscriptionSettingsView: View {
|
|||
}
|
||||
|
||||
private var allSupportedAlertTypes: PushSubscription.Alerts {
|
||||
var all: PushSubscription.Alerts = [.mention, .favorite, .reblog, .follow, .poll]
|
||||
var alerts: PushSubscription.Alerts = [.mention, .favorite, .reblog, .follow, .poll]
|
||||
if mastodonController.instanceFeatures.pushNotificationTypeFollowRequest {
|
||||
all.insert(.followRequest)
|
||||
alerts.insert(.followRequest)
|
||||
}
|
||||
if mastodonController.instanceFeatures.pushNotificationTypeUpdate {
|
||||
all.insert(.update)
|
||||
alerts.insert(.update)
|
||||
}
|
||||
if mastodonController.instanceFeatures.emojiReactionNotifications {
|
||||
all.insert(.emojiReaction)
|
||||
}
|
||||
return all
|
||||
return alerts
|
||||
}
|
||||
|
||||
private func toggle(_ titleKey: LocalizedStringKey, alert: PushSubscription.Alerts) -> some View {
|
||||
|
|
|
@ -172,8 +172,6 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
|
|||
return Status.getFavourites(statusID, range: range.withCount(Self.pageSize))
|
||||
case .reblog:
|
||||
return Status.getReblogs(statusID, range: range.withCount(Self.pageSize))
|
||||
case .emojiReaction(let name, _):
|
||||
return Status.getReactions(statusID, emoji: name, range: range.withCount(Self.pageSize))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
import WebURL
|
||||
|
||||
class StatusActionAccountListViewController: UIViewController {
|
||||
|
||||
|
@ -81,8 +80,6 @@ class StatusActionAccountListViewController: UIViewController {
|
|||
title = NSLocalizedString("Favorited By", comment: "status favorited by accounts list title")
|
||||
case .reblog:
|
||||
title = NSLocalizedString("Reblogged By", comment: "status reblogged by accounts list title")
|
||||
case .emojiReaction(_, _):
|
||||
title = "Reacted To By"
|
||||
}
|
||||
|
||||
view.backgroundColor = .appBackground
|
||||
|
@ -181,22 +178,7 @@ extension StatusActionAccountListViewController {
|
|||
|
||||
extension StatusActionAccountListViewController {
|
||||
enum ActionType {
|
||||
case favorite
|
||||
case reblog
|
||||
case emojiReaction(String, WebURL?)
|
||||
|
||||
init?(_ groupKind: NotificationGroup.Kind) {
|
||||
switch groupKind {
|
||||
case .reblog:
|
||||
self = .reblog
|
||||
case .favourite:
|
||||
self = .favorite
|
||||
case .emojiReaction(let emoji, let url):
|
||||
self = .emojiReaction(emoji, url)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
case favorite, reblog
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue