mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00

* New translations app.json (Thai) * New translations app.json (Spanish) * New translations Localizable.stringsdict (Spanish) * New translations app.json (Thai) * New translations app.json (Thai) * feat: adapt the app to async & await. Update timeline UI * fix: update the Xcode version to fix the CI failure * fix: remove unavailable framework import * fix: project dependency issue * feat: add content warning for post spoiler * feat: add content warning for post media * chore: update version to 1.3.0 (92) * New translations app.json (French) * New translations Intents.strings (French) * New translations app.json (Thai) * feat: update report flow * feat: update setting scene UI * feat: update status content warning UI * feat: add notification gap fetcher * chore: update version to 1.3.0 (93) * feat: add video player for audio/video kind media * chore: update version to 1.3.0 (94) * fix: text strip wrong color in the Dark Mode issue * chore: remove spoiler toggle animation for table cell * fix: add missing shadow for compose publish button * fix: add missing margin for timeline with horizontal regular size class * fix: profile segmented controls missing margin issue * fix: the profile segmented control use wrong selection tint color under force light UI style issue * fix: add notification count clear logic back * fix: add missing home timeline bottom fetcher * fix: [WIP] add suggestion account scene back * New translations app.json (Kabyle) * New translations ios-infoPlist.json (Kabyle) * New translations Localizable.stringsdict (Kabyle) * New translations Intents.strings (Kabyle) * New translations Intents.stringsdict (Kabyle) * feat: make the home timeline readable for VoiceOver * chore: update version to 1.3.0 (95) * New translations app.json (French) * New translations Intents.strings (French) * New translations app.json (Kabyle) * New translations ios-infoPlist.json (Kabyle) * New translations Localizable.stringsdict (Kabyle) * New translations Intents.strings (Kabyle) * New translations Intents.stringsdict (Kabyle) * New translations Localizable.stringsdict (French) * New translations app.json (Kabyle) * New translations app.json (French) * chore: update action toolbar icons * fix: instal state missing issue * fix: follow push notification deep-link not works issue * fix: foreground notification not trigger tab bell icon update issue * feat: add notification timeline fetcher * feat: add content warning toggle button * chore: update version to 1.3.0 (96) * New translations app.json (Thai) * New translations app.json (Russian) * New translations app.json (Kurmanji (Kurdish)) * New translations app.json (Scottish Gaelic) * New translations app.json (Welsh) * New translations app.json (Hindi) * New translations app.json (Spanish, Argentina) * New translations app.json (Indonesian) * New translations app.json (Portuguese, Brazilian) * New translations app.json (English) * New translations app.json (Chinese Traditional) * New translations app.json (Chinese Simplified) * New translations app.json (Swedish) * New translations app.json (Portuguese) * New translations app.json (Dutch) * New translations app.json (Korean) * New translations app.json (Japanese) * New translations app.json (Basque) * New translations app.json (German) * New translations app.json (Danish) * New translations app.json (Catalan) * New translations app.json (Arabic) * New translations app.json (Spanish) * New translations app.json (Romanian) * New translations app.json (Kabyle) * New translations app.json (French) * New translations app.json (Swedish, Finland) * New translations app.json (Spanish, Argentina) * New translations app.json (Kurmanji (Kurdish)) * fix: notification i18n word typo * New translations app.json (Thai) * New translations app.json (Swedish) * New translations Localizable.stringsdict (Swedish) * New translations app.json (Swedish, Finland) * New translations app.json (Kurmanji (Kurdish)) * New translations app.json (Scottish Gaelic) * New translations app.json (Welsh) * New translations app.json (Hindi) * New translations app.json (Indonesian) * New translations app.json (Portuguese, Brazilian) * New translations app.json (English) * New translations app.json (Chinese Traditional) * New translations app.json (Chinese Simplified) * New translations app.json (Russian) * New translations app.json (Portuguese) * New translations app.json (Dutch) * New translations app.json (Korean) * New translations app.json (Japanese) * New translations app.json (Basque) * New translations app.json (German) * New translations app.json (Danish) * New translations app.json (Catalan) * New translations app.json (Arabic) * New translations app.json (Spanish) * New translations app.json (Romanian) * New translations app.json (Kabyle) * New translations app.json (French) * New translations Intents.strings (Swedish) * New translations app.json (Swedish) * New translations Localizable.stringsdict (Japanese) * New translations app.json (Thai) * New translations app.json (Thai) * New translations Localizable.stringsdict (Swedish) * New translations app.json (Kabyle) * New translations ios-infoPlist.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (French) * New translations app.json (French) * feat: restore scroll-to-top tap gesture for TabBar * feat: add cell height cache for user timeline * feat: display no results when profile field empty * New translations app.json (Chinese Traditional) * New translations app.json (Chinese Traditional) * New translations Intents.strings (Japanese) * feat: make status detail accessible * chore: restore the appearance settings * chore: update version to 1.3.0 (97) * New translations app.json (Kabyle) * New translations Intents.strings (Japanese) * New translations app.json (Swedish) * New translations app.json (Basque) * New translations app.json (Basque) * chore: add a11y hint for profile dashboard * feat: add media interaction for notification timeline * New translations app.json (Chinese Simplified) * New translations app.json (Chinese Simplified) * chore: update i18n strings * fix: setting switch use wrong tint color issue * chore: restore RTL layout for post content * chore: update profile relationship button UI * chore: update color panel * fix: post reblog header may display empty reblogger name issue * fix: wrong reply header redirect logic issue * feat: restore post filter supports * chore: update version to 1.3.0 (98) * chore: update post content sensitive style * fix: blurhash image not display during image loading issue * chore: update version to 1.3.0 (99) * feat: restore user recommend scene * chore: update badge tint color * feat: restore keyboard shortcut supports * chore: update version to 1.3.0 (100) * fix: relationship background use wrong color when force dark style * fix: player button icon not reset issue * chore: update version to 1.3.0 (101) * fix: profile relationship button fill the width on iPad issue * fix: inputAssistantItem duplicate setup issue * chore: update textView minimum height from 88 to 64 * chore: update version to 1.3.0 (102) * chore: update status timeline margin * chore: update sidebar background color * fix: split view column state after size class transition not stable issue * chore: update notification timeline margin * chore: update profile header and segmented bar margin * fix: profile segmented bar use wrong tint color when force Dark Mode issue * chore: update horizontal compact mode notification timeline margin looks like * chore: update version to 1.3.0 (103) * feat: dismiss image preview when tap empty area * chore: update version to 1.3.0 (104) * New translations app.json (Italian) * New translations ios-infoPlist.json (Italian) * New translations Localizable.stringsdict (Italian) * New translations Intents.strings (Italian) * New translations Intents.stringsdict (Italian) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Japanese) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Spanish) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Kabyle) * New translations ios-infoPlist.json (Kabyle) * New translations Localizable.stringsdict (Kabyle) * New translations Localizable.stringsdict (Kabyle) * New translations Intents.strings (Kabyle) * New translations app.json (Kabyle) * New translations Intents.strings (Kabyle) * New translations Intents.stringsdict (Kabyle) * New translations app.json (Kabyle) * New translations app.json (Scottish Gaelic) * New translations app.json (Scottish Gaelic) * New translations app.json (Thai) * New translations app.json (Thai) * feat: add UITests for snapshots * feat: add snapshot UITest and document * New translations app.json (Thai) * feat: add notification snapshot * chore: add domain and update guide for the snapshot UITest * chore: use the first photo for compose snapshot * New translations app.json (Thai) * New translations app.json (German) * New translations app.json (German) * chore: update settings scene UI * chore: update i18n for open link words * chore: update i18n resources * fix: share extension not accept plaintext content issue. resolve #335 * chore: update version to 1.3.0 (105) * New translations app.json (Japanese) * New translations app.json (Japanese) * New translations app.json (Japanese) * feat: add onion domain ATS exception rule. resolve #338 * chore: update app version footer and i18n strings * chore: update version to 1.3.0 (106) * chore: update version to 1.3.0 (108) * Handle onboarding authentication errors in /api/v1/instance * New translations app.json (Kurmanji (Kurdish)) * New translations app.json (Kurmanji (Kurdish)) * chore: update Xcode schemes index * chore: update the snapshot documents and UITests * chore: update i18n resources. resolve #343 * chore: retain the API model semantic * fix: force LTR for some text fields. #318 * fix: textView break IME input issue. resolve #342 * chore: update version to 1.3.0 (109) * chore: update README * chore: fix typo * chore: add bug report template and contributing document Co-authored-by: Eugen Rochko <eugen@zeonfederated.com> Co-authored-by: Zac West <zacwest@gmail.com>
208 lines
5.7 KiB
Swift
208 lines
5.7 KiB
Swift
//
|
|
// Notification.swift
|
|
// CoreDataStack
|
|
//
|
|
// Created by sxiaojian on 2021/4/13.
|
|
//
|
|
|
|
import Foundation
|
|
import CoreData
|
|
|
|
public final class Notification: NSManagedObject {
|
|
public typealias ID = String
|
|
|
|
// sourcery: autoGenerateProperty
|
|
@NSManaged public private(set) var id: ID
|
|
// sourcery: autoGenerateProperty
|
|
@NSManaged public private(set) var typeRaw: String
|
|
// sourcery: autoGenerateProperty
|
|
@NSManaged public private(set) var domain: String
|
|
// sourcery: autoGenerateProperty
|
|
@NSManaged public private(set) var userID: String
|
|
|
|
// sourcery: autoGenerateProperty
|
|
@NSManaged public private(set) var createAt: Date
|
|
// sourcery: autoUpdatableObject, autoGenerateProperty
|
|
@NSManaged public private(set) var updatedAt: Date
|
|
|
|
// one-to-one relationship
|
|
// sourcery: autoGenerateRelationship
|
|
@NSManaged public private(set) var account: MastodonUser
|
|
// sourcery: autoGenerateRelationship
|
|
@NSManaged public private(set) var status: Status?
|
|
|
|
// many-to-one relationship
|
|
@NSManaged public private(set) var feeds: Set<Feed>
|
|
|
|
}
|
|
|
|
extension Notification: FeedIndexable { }
|
|
|
|
extension Notification {
|
|
@discardableResult
|
|
public static func insert(
|
|
into context: NSManagedObjectContext,
|
|
property: Property,
|
|
relationship: Relationship
|
|
) -> Notification {
|
|
let object: Notification = context.insertObject()
|
|
|
|
object.configure(property: property)
|
|
object.configure(relationship: relationship)
|
|
|
|
return object
|
|
}
|
|
}
|
|
|
|
extension Notification: Managed {
|
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
|
return [NSSortDescriptor(keyPath: \Notification.createAt, ascending: false)]
|
|
}
|
|
}
|
|
|
|
extension Notification {
|
|
static func predicate(domain: String) -> NSPredicate {
|
|
return NSPredicate(format: "%K == %@", #keyPath(Notification.domain), domain)
|
|
}
|
|
|
|
static func predicate(userID: String) -> NSPredicate {
|
|
return NSPredicate(format: "%K == %@", #keyPath(Notification.userID), userID)
|
|
}
|
|
|
|
static func predicate(id: ID) -> NSPredicate {
|
|
return NSPredicate(format: "%K == %@", #keyPath(Notification.id), id)
|
|
}
|
|
|
|
static func predicate(typeRaw: String) -> NSPredicate {
|
|
return NSPredicate(format: "%K == %@", #keyPath(Notification.typeRaw), typeRaw)
|
|
}
|
|
|
|
public static func predicate(
|
|
domain: String,
|
|
userID: String,
|
|
id: ID
|
|
) -> NSPredicate {
|
|
return NSCompoundPredicate(andPredicateWithSubpredicates: [
|
|
Notification.predicate(domain: domain),
|
|
Notification.predicate(userID: userID),
|
|
Notification.predicate(id: id)
|
|
])
|
|
}
|
|
|
|
public static func predicate(
|
|
domain: String,
|
|
userID: String,
|
|
typeRaw: String? = nil
|
|
) -> NSPredicate {
|
|
if let typeRaw = typeRaw {
|
|
return NSCompoundPredicate(andPredicateWithSubpredicates: [
|
|
Notification.predicate(domain: domain),
|
|
Notification.predicate(typeRaw: typeRaw),
|
|
Notification.predicate(userID: userID),
|
|
])
|
|
} else {
|
|
return NSCompoundPredicate(andPredicateWithSubpredicates: [
|
|
Notification.predicate(domain: domain),
|
|
Notification.predicate(userID: userID)
|
|
])
|
|
}
|
|
}
|
|
|
|
public static func predicate(validTypesRaws types: [String]) -> NSPredicate {
|
|
return NSPredicate(format: "%K IN %@", #keyPath(Notification.typeRaw), types)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - AutoGenerateProperty
|
|
extension Notification: AutoGenerateProperty {
|
|
// sourcery:inline:Notification.AutoGenerateProperty
|
|
|
|
// Generated using Sourcery
|
|
// DO NOT EDIT
|
|
public struct Property {
|
|
public let id: ID
|
|
public let typeRaw: String
|
|
public let domain: String
|
|
public let userID: String
|
|
public let createAt: Date
|
|
public let updatedAt: Date
|
|
|
|
public init(
|
|
id: ID,
|
|
typeRaw: String,
|
|
domain: String,
|
|
userID: String,
|
|
createAt: Date,
|
|
updatedAt: Date
|
|
) {
|
|
self.id = id
|
|
self.typeRaw = typeRaw
|
|
self.domain = domain
|
|
self.userID = userID
|
|
self.createAt = createAt
|
|
self.updatedAt = updatedAt
|
|
}
|
|
}
|
|
|
|
public func configure(property: Property) {
|
|
self.id = property.id
|
|
self.typeRaw = property.typeRaw
|
|
self.domain = property.domain
|
|
self.userID = property.userID
|
|
self.createAt = property.createAt
|
|
self.updatedAt = property.updatedAt
|
|
}
|
|
|
|
public func update(property: Property) {
|
|
update(updatedAt: property.updatedAt)
|
|
}
|
|
// sourcery:end
|
|
}
|
|
|
|
// MARK: - AutoGenerateRelationship
|
|
extension Notification: AutoGenerateRelationship {
|
|
// sourcery:inline:Notification.AutoGenerateRelationship
|
|
|
|
// Generated using Sourcery
|
|
// DO NOT EDIT
|
|
public struct Relationship {
|
|
public let account: MastodonUser
|
|
public let status: Status?
|
|
|
|
public init(
|
|
account: MastodonUser,
|
|
status: Status?
|
|
) {
|
|
self.account = account
|
|
self.status = status
|
|
}
|
|
}
|
|
|
|
public func configure(relationship: Relationship) {
|
|
self.account = relationship.account
|
|
self.status = relationship.status
|
|
}
|
|
// sourcery:end
|
|
}
|
|
|
|
// MARK: - AutoUpdatableObject
|
|
extension Notification: AutoUpdatableObject {
|
|
// sourcery:inline:Notification.AutoUpdatableObject
|
|
|
|
// Generated using Sourcery
|
|
// DO NOT EDIT
|
|
public func update(updatedAt: Date) {
|
|
if self.updatedAt != updatedAt {
|
|
self.updatedAt = updatedAt
|
|
}
|
|
}
|
|
// sourcery:end
|
|
}
|
|
|
|
extension Notification {
|
|
public func attach(feed: Feed) {
|
|
mutableSetValue(forKey: #keyPath(Notification.feeds)).add(feed)
|
|
}
|
|
}
|