Kurdtvs-Live-Kurdish-TV-Kur.../Mastodon/Diffiable/Item/NotificationItem.swift

51 lines
1.2 KiB
Swift
Raw Normal View History

2021-04-12 10:31:53 +02:00
//
// NotificationItem.swift
// Mastodon
//
// Created by sxiaojian on 2021/4/13.
//
import CoreData
2021-04-15 04:16:30 +02:00
import Foundation
2021-04-12 10:31:53 +02:00
enum NotificationItem {
case notification(objectID: NSManagedObjectID, attribute: Item.StatusAttribute)
2021-04-12 10:31:53 +02:00
case bottomLoader
}
extension NotificationItem: Equatable {
static func == (lhs: NotificationItem, rhs: NotificationItem) -> Bool {
switch (lhs, rhs) {
case (.notification(let idLeft, _), .notification(let idRight, _)):
2021-04-12 10:31:53 +02:00
return idLeft == idRight
2021-04-16 07:45:54 +02:00
case (.bottomLoader, .bottomLoader):
return true
2021-04-12 10:31:53 +02:00
default:
return false
}
}
}
extension NotificationItem: Hashable {
func hash(into hasher: inout Hasher) {
switch self {
case .notification(let id, _):
2021-04-12 10:31:53 +02:00
hasher.combine(id)
case .bottomLoader:
hasher.combine(String(describing: NotificationItem.bottomLoader.self))
}
}
}
extension NotificationItem {
var statusObjectItem: StatusObjectItem? {
switch self {
case .notification(let objectID, _):
return .mastodonNotification(objectID: objectID)
case .bottomLoader:
return nil
}
}
}