code format and resolve all the comments.
This commit is contained in:
parent
7c19e569c9
commit
03dd6a7329
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20D5029f" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20D5029f" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||||
<entity name="Emoji" representedClassName=".Emoji" syncable="YES">
|
<entity name="Emoji" representedClassName=".Emoji" syncable="YES">
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="category" optional="YES" attributeType="String"/>
|
||||||
|
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
|
||||||
<attribute name="shortcode" attributeType="String"/>
|
<attribute name="shortcode" attributeType="String"/>
|
||||||
<attribute name="staticURL" attributeType="String"/>
|
<attribute name="staticURL" attributeType="String"/>
|
||||||
<attribute name="url" attributeType="String"/>
|
<attribute name="url" attributeType="String"/>
|
||||||
|
@ -10,9 +12,11 @@
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="History" representedClassName=".History" syncable="YES">
|
<entity name="History" representedClassName=".History" syncable="YES">
|
||||||
<attribute name="accounts" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="accounts" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
|
||||||
<attribute name="day" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="day" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="identifier" optional="YES" attributeType="String"/>
|
<attribute name="identifier" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
|
||||||
<attribute name="uses" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="uses" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
|
<relationship name="tag" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Tag" inverseName="histories" inverseEntity="Tag"/>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="HomeTimelineIndex" representedClassName=".HomeTimelineIndex" syncable="YES">
|
<entity name="HomeTimelineIndex" representedClassName=".HomeTimelineIndex" syncable="YES">
|
||||||
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
|
@ -23,50 +27,52 @@
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="MastodonUser" representedClassName=".MastodonUser" syncable="YES">
|
<entity name="MastodonUser" representedClassName=".MastodonUser" syncable="YES">
|
||||||
<attribute name="acct" attributeType="String"/>
|
<attribute name="acct" attributeType="String"/>
|
||||||
<attribute name="avatar" optional="YES" attributeType="String"/>
|
<attribute name="avatar" attributeType="String"/>
|
||||||
<attribute name="avatarStatic" optional="YES" attributeType="String"/>
|
<attribute name="avatarStatic" optional="YES" attributeType="String"/>
|
||||||
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="displayName" optional="YES" attributeType="String"/>
|
<attribute name="displayName" attributeType="String"/>
|
||||||
<attribute name="domain" attributeType="String"/>
|
<attribute name="domain" attributeType="String"/>
|
||||||
<attribute name="id" attributeType="String"/>
|
<attribute name="id" attributeType="String"/>
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="identifier" attributeType="String"/>
|
||||||
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="username" attributeType="String"/>
|
<attribute name="username" attributeType="String"/>
|
||||||
|
<relationship name="bookmarked" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="bookmarked" inverseEntity="Toot"/>
|
||||||
|
<relationship name="favourite" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="favouritedBy" inverseEntity="Toot"/>
|
||||||
|
<relationship name="muted" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="mutedBy" inverseEntity="Toot"/>
|
||||||
|
<relationship name="pinnedToot" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="pinnedBy" inverseEntity="Toot"/>
|
||||||
|
<relationship name="reblogged" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="rebloggedBy" inverseEntity="Toot"/>
|
||||||
<relationship name="toots" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="author" inverseEntity="Toot"/>
|
<relationship name="toots" toMany="YES" deletionRule="Nullify" destinationEntity="Toot" inverseName="author" inverseEntity="Toot"/>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="Mention" representedClassName=".Mention" syncable="YES">
|
<entity name="Mention" representedClassName=".Mention" syncable="YES">
|
||||||
<attribute name="acct" attributeType="String"/>
|
<attribute name="acct" attributeType="String"/>
|
||||||
|
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
|
||||||
<attribute name="id" attributeType="String"/>
|
<attribute name="id" attributeType="String"/>
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
|
||||||
<attribute name="url" attributeType="String"/>
|
<attribute name="url" attributeType="String"/>
|
||||||
<attribute name="username" attributeType="String"/>
|
<attribute name="username" attributeType="String"/>
|
||||||
<relationship name="toot" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="mentions" inverseEntity="Toot"/>
|
<relationship name="toot" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="mentions" inverseEntity="Toot"/>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="Tag" representedClassName=".Tag" syncable="YES">
|
<entity name="Tag" representedClassName=".Tag" syncable="YES">
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
|
||||||
|
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
|
||||||
<attribute name="name" attributeType="String"/>
|
<attribute name="name" attributeType="String"/>
|
||||||
<attribute name="url" attributeType="String"/>
|
<attribute name="url" attributeType="String"/>
|
||||||
<relationship name="history" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="History"/>
|
<relationship name="histories" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="History" inverseName="tag" inverseEntity="History"/>
|
||||||
<relationship name="toot" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="tags" inverseEntity="Toot"/>
|
<relationship name="toot" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="tags" inverseEntity="Toot"/>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="Toot" representedClassName=".Toot" syncable="YES">
|
<entity name="Toot" representedClassName=".Toot" syncable="YES">
|
||||||
<attribute name="bookmarked" attributeType="Boolean" usesScalarValueType="YES"/>
|
|
||||||
<attribute name="content" attributeType="String"/>
|
<attribute name="content" attributeType="String"/>
|
||||||
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="deletedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="deletedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="domain" attributeType="String"/>
|
<attribute name="domain" attributeType="String"/>
|
||||||
<attribute name="favourited" attributeType="Boolean" usesScalarValueType="YES"/>
|
|
||||||
<attribute name="favouritesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="favouritesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
<attribute name="id" attributeType="String"/>
|
<attribute name="id" attributeType="String"/>
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="identifier" attributeType="String"/>
|
||||||
<attribute name="inReplyToAccountID" optional="YES" attributeType="String"/>
|
<attribute name="inReplyToAccountID" optional="YES" attributeType="String"/>
|
||||||
<attribute name="inReplyToID" optional="YES" attributeType="String"/>
|
<attribute name="inReplyToID" optional="YES" attributeType="String"/>
|
||||||
<attribute name="language" optional="YES" attributeType="String"/>
|
<attribute name="language" optional="YES" attributeType="String"/>
|
||||||
<attribute name="muted" attributeType="Boolean" usesScalarValueType="YES"/>
|
|
||||||
<attribute name="pinned" attributeType="Boolean" usesScalarValueType="YES"/>
|
|
||||||
<attribute name="reblogged" attributeType="Boolean" usesScalarValueType="YES"/>
|
|
||||||
<attribute name="reblogsCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="reblogsCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
<attribute name="repliesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="repliesCount" optional="YES" attributeType="Integer 64" usesScalarValueType="NO"/>
|
||||||
<attribute name="sensitive" attributeType="Boolean" usesScalarValueType="YES"/>
|
<attribute name="sensitive" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||||
<attribute name="spoilerText" optional="YES" attributeType="String"/>
|
<attribute name="spoilerText" optional="YES" attributeType="String"/>
|
||||||
<attribute name="text" optional="YES" attributeType="String"/>
|
<attribute name="text" optional="YES" attributeType="String"/>
|
||||||
|
@ -75,19 +81,24 @@
|
||||||
<attribute name="url" attributeType="String"/>
|
<attribute name="url" attributeType="String"/>
|
||||||
<attribute name="visibility" optional="YES" attributeType="String"/>
|
<attribute name="visibility" optional="YES" attributeType="String"/>
|
||||||
<relationship name="author" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="toots" inverseEntity="MastodonUser"/>
|
<relationship name="author" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="toots" inverseEntity="MastodonUser"/>
|
||||||
<relationship name="emojis" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Emoji" inverseName="toot" inverseEntity="Emoji"/>
|
<relationship name="bookmarked" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="bookmarked" inverseEntity="MastodonUser"/>
|
||||||
|
<relationship name="emojis" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Emoji" inverseName="toot" inverseEntity="Emoji"/>
|
||||||
|
<relationship name="favouritedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="favourite" inverseEntity="MastodonUser"/>
|
||||||
<relationship name="homeTimelineIndexes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="HomeTimelineIndex" inverseName="toots" inverseEntity="HomeTimelineIndex"/>
|
<relationship name="homeTimelineIndexes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="HomeTimelineIndex" inverseName="toots" inverseEntity="HomeTimelineIndex"/>
|
||||||
<relationship name="mentions" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mention" inverseName="toot" inverseEntity="Mention"/>
|
<relationship name="mentions" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Mention" inverseName="toot" inverseEntity="Mention"/>
|
||||||
|
<relationship name="mutedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="muted" inverseEntity="MastodonUser"/>
|
||||||
|
<relationship name="pinnedBy" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="pinnedToot" inverseEntity="MastodonUser"/>
|
||||||
<relationship name="reblog" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="reblog" inverseEntity="Toot"/>
|
<relationship name="reblog" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Toot" inverseName="reblog" inverseEntity="Toot"/>
|
||||||
<relationship name="tags" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Tag" inverseName="toot" inverseEntity="Tag"/>
|
<relationship name="rebloggedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="reblogged" inverseEntity="MastodonUser"/>
|
||||||
|
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Tag" inverseName="toot" inverseEntity="Tag"/>
|
||||||
</entity>
|
</entity>
|
||||||
<elements>
|
<elements>
|
||||||
<element name="Emoji" positionX="45" positionY="135" width="128" height="119"/>
|
<element name="Emoji" positionX="45" positionY="135" width="128" height="149"/>
|
||||||
<element name="History" positionX="27" positionY="126" width="128" height="89"/>
|
<element name="History" positionX="27" positionY="126" width="128" height="119"/>
|
||||||
<element name="HomeTimelineIndex" positionX="0" positionY="0" width="128" height="104"/>
|
<element name="HomeTimelineIndex" positionX="0" positionY="0" width="128" height="104"/>
|
||||||
<element name="MastodonUser" positionX="0" positionY="0" width="128" height="194"/>
|
<element name="MastodonUser" positionX="0" positionY="0" width="128" height="269"/>
|
||||||
<element name="Mention" positionX="9" positionY="108" width="128" height="119"/>
|
<element name="Mention" positionX="9" positionY="108" width="128" height="134"/>
|
||||||
<element name="Tag" positionX="18" positionY="117" width="128" height="104"/>
|
<element name="Tag" positionX="18" positionY="117" width="128" height="119"/>
|
||||||
<element name="Toot" positionX="0" positionY="0" width="128" height="479"/>
|
<element name="Toot" positionX="0" positionY="0" width="128" height="479"/>
|
||||||
</elements>
|
</elements>
|
||||||
</model>
|
</model>
|
|
@ -9,24 +9,32 @@ import CoreData
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public final class Emoji: NSManagedObject {
|
public final class Emoji: NSManagedObject {
|
||||||
public typealias ID = String
|
public typealias ID = UUID
|
||||||
@NSManaged public private(set) var identifier: ID
|
@NSManaged public private(set) var identifier: ID
|
||||||
|
@NSManaged public private(set) var createAt: Date
|
||||||
|
|
||||||
@NSManaged public private(set) var shortcode: String
|
@NSManaged public private(set) var shortcode: String
|
||||||
@NSManaged public private(set) var url: String
|
@NSManaged public private(set) var url: String
|
||||||
@NSManaged public private(set) var staticURL: String
|
@NSManaged public private(set) var staticURL: String
|
||||||
@NSManaged public private(set) var visibleInPicker: Bool
|
@NSManaged public private(set) var visibleInPicker: Bool
|
||||||
|
@NSManaged public private(set) var category: String?
|
||||||
|
|
||||||
|
// many-to-one relationship
|
||||||
@NSManaged public private(set) var toot: Toot?
|
@NSManaged public private(set) var toot: Toot?
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Emoji {
|
public extension Emoji {
|
||||||
|
override func awakeFromInsert() {
|
||||||
|
super.awakeFromInsert()
|
||||||
|
identifier = UUID()
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
static func insert(
|
static func insert(
|
||||||
into context: NSManagedObjectContext,
|
into context: NSManagedObjectContext,
|
||||||
property: Property
|
property: Property
|
||||||
) -> Emoji {
|
) -> Emoji {
|
||||||
let emoji: Emoji = context.insertObject()
|
let emoji: Emoji = context.insertObject()
|
||||||
|
|
||||||
emoji.identifier = UUID().uuidString
|
|
||||||
emoji.shortcode = property.shortcode
|
emoji.shortcode = property.shortcode
|
||||||
emoji.url = property.url
|
emoji.url = property.url
|
||||||
emoji.staticURL = property.staticURL
|
emoji.staticURL = property.staticURL
|
||||||
|
@ -42,18 +50,21 @@ public extension Emoji {
|
||||||
public let url: String
|
public let url: String
|
||||||
public let staticURL: String
|
public let staticURL: String
|
||||||
public let visibleInPicker: Bool
|
public let visibleInPicker: Bool
|
||||||
|
public let category: String?
|
||||||
|
|
||||||
public init(shortcode: String, url: String, staticURL: String, visibleInPicker: Bool) {
|
public init(shortcode: String, url: String, staticURL: String, visibleInPicker: Bool, category: String?) {
|
||||||
self.shortcode = shortcode
|
self.shortcode = shortcode
|
||||||
self.url = url
|
self.url = url
|
||||||
self.staticURL = staticURL
|
self.staticURL = staticURL
|
||||||
self.visibleInPicker = visibleInPicker
|
self.visibleInPicker = visibleInPicker
|
||||||
|
self.category = category
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Emoji: Managed {
|
extension Emoji: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \Emoji.identifier, ascending: false)]
|
return [NSSortDescriptor(keyPath: \Emoji.createAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,52 +5,57 @@
|
||||||
// Created by sxiaojian on 2021/2/1.
|
// Created by sxiaojian on 2021/2/1.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import CoreData
|
import CoreData
|
||||||
|
import Foundation
|
||||||
|
|
||||||
final public class History: NSManagedObject {
|
public final class History: NSManagedObject {
|
||||||
|
public typealias ID = UUID
|
||||||
public typealias ID = String
|
|
||||||
@NSManaged public private(set) var identifier: ID
|
@NSManaged public private(set) var identifier: ID
|
||||||
|
@NSManaged public private(set) var createAt: Date
|
||||||
|
|
||||||
@NSManaged public private(set) var day: Date
|
@NSManaged public private(set) var day: Date
|
||||||
@NSManaged public private(set) var uses: Int
|
@NSManaged public private(set) var uses: Int
|
||||||
@NSManaged public private(set) var accounts: Int
|
@NSManaged public private(set) var accounts: Int
|
||||||
@NSManaged public private(set) var tag: Tag?
|
|
||||||
|
// many-to-one relationship
|
||||||
|
@NSManaged public private(set) var tag: Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
extension History {
|
public extension History {
|
||||||
|
override func awakeFromInsert() {
|
||||||
|
super.awakeFromInsert()
|
||||||
|
identifier = UUID()
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public static func insert(
|
static func insert(
|
||||||
into context: NSManagedObjectContext,
|
into context: NSManagedObjectContext,
|
||||||
property:Property
|
property: Property
|
||||||
) -> History {
|
) -> History {
|
||||||
let history :History = context.insertObject()
|
let history: History = context.insertObject()
|
||||||
|
history.day = property.day
|
||||||
history.identifier = UUID().uuidString
|
history.uses = property.uses
|
||||||
history.day = property.day
|
history.accounts = property.accounts
|
||||||
history.uses = property.uses
|
|
||||||
history.accounts = property.accounts
|
|
||||||
return history
|
return history
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension History {
|
public extension History {
|
||||||
public struct Property {
|
struct Property {
|
||||||
|
|
||||||
public let day: Date
|
public let day: Date
|
||||||
public let uses: Int
|
public let uses: Int
|
||||||
public let accounts: Int
|
public let accounts: Int
|
||||||
|
|
||||||
public init(day: Date, uses: Int, accounts: Int) {
|
public init(day: Date, uses: Int, accounts: Int) {
|
||||||
self.day = day
|
self.day = day
|
||||||
self.uses = uses
|
self.uses = uses
|
||||||
self.accounts = accounts
|
self.accounts = accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension History: Managed {
|
extension History: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \History.identifier, ascending: false)]
|
return [NSSortDescriptor(keyPath: \History.createAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,10 @@
|
||||||
// Created by MainasuK Cirno on 2021/1/27.
|
// Created by MainasuK Cirno on 2021/1/27.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import CoreData
|
import CoreData
|
||||||
|
import Foundation
|
||||||
|
|
||||||
final public class MastodonUser: NSManagedObject {
|
public final class MastodonUser: NSManagedObject {
|
||||||
|
|
||||||
public typealias ID = String
|
public typealias ID = String
|
||||||
@NSManaged public private(set) var identifier: ID
|
@NSManaged public private(set) var identifier: ID
|
||||||
@NSManaged public private(set) var domain: String
|
@NSManaged public private(set) var domain: String
|
||||||
|
@ -17,22 +16,31 @@ final public class MastodonUser: NSManagedObject {
|
||||||
@NSManaged public private(set) var id: String
|
@NSManaged public private(set) var id: String
|
||||||
@NSManaged public private(set) var acct: String
|
@NSManaged public private(set) var acct: String
|
||||||
@NSManaged public private(set) var username: String
|
@NSManaged public private(set) var username: String
|
||||||
@NSManaged public private(set) var displayName: String?
|
@NSManaged public private(set) var displayName: String
|
||||||
@NSManaged public private(set) var avatar: String
|
@NSManaged public private(set) var avatar: String
|
||||||
@NSManaged public private(set) var avatarStatic: String
|
@NSManaged public private(set) var avatarStatic: String?
|
||||||
|
|
||||||
|
|
||||||
@NSManaged public private(set) var createdAt: Date
|
@NSManaged public private(set) var createdAt: Date
|
||||||
@NSManaged public private(set) var updatedAt: Date
|
@NSManaged public private(set) var updatedAt: Date
|
||||||
|
|
||||||
|
// one-to-one relationship
|
||||||
|
@NSManaged public private(set) var pinnedToot: Toot?
|
||||||
|
|
||||||
|
// one-to-many relationship
|
||||||
@NSManaged public private(set) var toots: Set<Toot>?
|
@NSManaged public private(set) var toots: Set<Toot>?
|
||||||
|
|
||||||
|
// many-to-many relationship
|
||||||
|
@NSManaged public private(set) var favourite: Set<Toot>?
|
||||||
|
@NSManaged public private(set) var reblogged: Set<Toot>?
|
||||||
|
@NSManaged public private(set) var muted: Set<Toot>?
|
||||||
|
@NSManaged public private(set) var bookmarked: Set<Toot>?
|
||||||
|
|
||||||
|
@NSManaged public private(set) var retweets: Set<Toot>?
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonUser {
|
public extension MastodonUser {
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public static func insert(
|
static func insert(
|
||||||
into context: NSManagedObjectContext,
|
into context: NSManagedObjectContext,
|
||||||
property: Property
|
property: Property
|
||||||
) -> MastodonUser {
|
) -> MastodonUser {
|
||||||
|
@ -53,20 +61,19 @@ extension MastodonUser {
|
||||||
|
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonUser {
|
public extension MastodonUser {
|
||||||
public struct Property {
|
struct Property {
|
||||||
public let identifier: String
|
public let identifier: String
|
||||||
public let domain: String
|
public let domain: String
|
||||||
|
|
||||||
public let id: String
|
public let id: String
|
||||||
public let acct: String
|
public let acct: String
|
||||||
public let username: String
|
public let username: String
|
||||||
public let displayName: String?
|
public let displayName: String
|
||||||
public let avatar: String
|
public let avatar: String
|
||||||
public let avatarStatic: String
|
public let avatarStatic: String?
|
||||||
|
|
||||||
public let createdAt: Date
|
public let createdAt: Date
|
||||||
public let networkDate: Date
|
public let networkDate: Date
|
||||||
|
@ -76,9 +83,9 @@ extension MastodonUser {
|
||||||
domain: String,
|
domain: String,
|
||||||
acct: String,
|
acct: String,
|
||||||
username: String,
|
username: String,
|
||||||
displayName: String?,
|
displayName: String,
|
||||||
avatar:String,
|
avatar: String,
|
||||||
avatarStatic:String,
|
avatarStatic: String?,
|
||||||
createdAt: Date,
|
createdAt: Date,
|
||||||
networkDate: Date
|
networkDate: Date
|
||||||
) {
|
) {
|
||||||
|
@ -87,9 +94,7 @@ extension MastodonUser {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.acct = acct
|
self.acct = acct
|
||||||
self.username = username
|
self.username = username
|
||||||
self.displayName = displayName.flatMap { displayName in
|
self.displayName = displayName
|
||||||
return displayName.isEmpty ? nil : displayName
|
|
||||||
}
|
|
||||||
self.avatar = avatar
|
self.avatar = avatar
|
||||||
self.avatarStatic = avatarStatic
|
self.avatarStatic = avatarStatic
|
||||||
self.createdAt = createdAt
|
self.createdAt = createdAt
|
||||||
|
@ -103,4 +108,3 @@ extension MastodonUser: Managed {
|
||||||
return [NSSortDescriptor(keyPath: \MastodonUser.createdAt, ascending: false)]
|
return [NSSortDescriptor(keyPath: \MastodonUser.createdAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,29 +5,35 @@
|
||||||
// Created by sxiaojian on 2021/2/1.
|
// Created by sxiaojian on 2021/2/1.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import CoreData
|
import CoreData
|
||||||
|
import Foundation
|
||||||
|
|
||||||
final public class Mention: NSManagedObject {
|
public final class Mention: NSManagedObject {
|
||||||
|
public typealias ID = UUID
|
||||||
public typealias ID = String
|
|
||||||
@NSManaged public private(set) var identifier: ID
|
@NSManaged public private(set) var identifier: ID
|
||||||
@NSManaged public private(set) var id: String
|
@NSManaged public private(set) var id: String
|
||||||
|
@NSManaged public private(set) var createAt: Date
|
||||||
|
|
||||||
@NSManaged public private(set) var username: String
|
@NSManaged public private(set) var username: String
|
||||||
@NSManaged public private(set) var acct: String
|
@NSManaged public private(set) var acct: String
|
||||||
@NSManaged public private(set) var url: String
|
@NSManaged public private(set) var url: String
|
||||||
@NSManaged public private(set) var toot: Toot?
|
|
||||||
|
// many-to-one relationship
|
||||||
|
@NSManaged public private(set) var toot: Toot
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Mention {
|
public extension Mention {
|
||||||
|
override func awakeFromInsert() {
|
||||||
|
super.awakeFromInsert()
|
||||||
|
identifier = UUID()
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
public static func insert(
|
static func insert(
|
||||||
into context: NSManagedObjectContext,
|
into context: NSManagedObjectContext,
|
||||||
property:Property
|
property: Property
|
||||||
) -> Mention {
|
) -> Mention {
|
||||||
let mention :Mention = context.insertObject()
|
let mention: Mention = context.insertObject()
|
||||||
|
|
||||||
mention.identifier = UUID().uuidString
|
|
||||||
mention.id = property.id
|
mention.id = property.id
|
||||||
mention.username = property.username
|
mention.username = property.username
|
||||||
mention.acct = property.acct
|
mention.acct = property.acct
|
||||||
|
@ -36,13 +42,13 @@ extension Mention {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Mention {
|
public extension Mention {
|
||||||
public struct Property {
|
struct Property {
|
||||||
public let id: String
|
public let id: String
|
||||||
public let username: String
|
public let username: String
|
||||||
public let acct: String
|
public let acct: String
|
||||||
public let url: String
|
public let url: String
|
||||||
|
|
||||||
public init(id: String, username: String, acct: String, url: String) {
|
public init(id: String, username: String, acct: String, url: String) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.username = username
|
self.username = username
|
||||||
|
@ -54,6 +60,6 @@ extension Mention {
|
||||||
|
|
||||||
extension Mention: Managed {
|
extension Mention: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \Mention.id, ascending: false)]
|
return [NSSortDescriptor(keyPath: \Mention.createAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,27 +9,34 @@ import CoreData
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public final class Tag: NSManagedObject {
|
public final class Tag: NSManagedObject {
|
||||||
public typealias ID = String
|
public typealias ID = UUID
|
||||||
@NSManaged public private(set) var identifier: ID
|
@NSManaged public private(set) var identifier: ID
|
||||||
|
@NSManaged public private(set) var createAt: Date
|
||||||
|
|
||||||
@NSManaged public private(set) var name: String
|
@NSManaged public private(set) var name: String
|
||||||
@NSManaged public private(set) var url: String
|
@NSManaged public private(set) var url: String
|
||||||
//on to many
|
|
||||||
@NSManaged public private(set) var history: [History]?
|
// one-to-many relationship
|
||||||
|
@NSManaged public private(set) var histories: Set<History>?
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Tag {
|
public extension Tag {
|
||||||
|
override func awakeFromInsert() {
|
||||||
|
super.awakeFromInsert()
|
||||||
|
identifier = UUID()
|
||||||
|
}
|
||||||
@discardableResult
|
@discardableResult
|
||||||
static func insert(
|
static func insert(
|
||||||
into context: NSManagedObjectContext,
|
into context: NSManagedObjectContext,
|
||||||
property: Property
|
property: Property
|
||||||
) -> Tag {
|
) -> Tag {
|
||||||
let Tag: Tag = context.insertObject()
|
let tag: Tag = context.insertObject()
|
||||||
|
tag.name = property.name
|
||||||
Tag.identifier = UUID().uuidString
|
tag.url = property.url
|
||||||
Tag.name = property.name
|
if let histories = property.histories {
|
||||||
Tag.url = property.url
|
tag.mutableSetValue(forKey: #keyPath(Tag.histories)).addObjects(from: histories)
|
||||||
Tag.history = property.history
|
}
|
||||||
return Tag
|
return tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,18 +44,18 @@ public extension Tag {
|
||||||
struct Property {
|
struct Property {
|
||||||
public let name: String
|
public let name: String
|
||||||
public let url: String
|
public let url: String
|
||||||
public let history: [History]?
|
public let histories: [History]?
|
||||||
|
|
||||||
public init(name: String, url: String, history: [History]?) {
|
public init(name: String, url: String, histories: [History]?) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.url = url
|
self.url = url
|
||||||
self.history = history
|
self.histories = histories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Tag: Managed {
|
extension Tag: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \Tag.identifier, ascending: false)]
|
return [NSSortDescriptor(keyPath: \Tag.createAt, ascending: false)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,33 +22,40 @@ public final class Toot: NSManagedObject {
|
||||||
@NSManaged public private(set) var sensitive: Bool
|
@NSManaged public private(set) var sensitive: Bool
|
||||||
@NSManaged public private(set) var spoilerText: String?
|
@NSManaged public private(set) var spoilerText: String?
|
||||||
|
|
||||||
// rendering
|
|
||||||
//one to many
|
|
||||||
@NSManaged public private(set) var mentions: Set<Mention>?
|
|
||||||
//one to many
|
|
||||||
@NSManaged public private(set) var emojis: Set<Emoji>?
|
|
||||||
//one to many
|
|
||||||
@NSManaged public private(set) var tags: [Tag]?
|
|
||||||
// Informational
|
// Informational
|
||||||
@NSManaged public private(set) var reblogsCount: Int
|
@NSManaged public private(set) var reblogsCount: NSNumber
|
||||||
@NSManaged public private(set) var favouritesCount: Int
|
@NSManaged public private(set) var favouritesCount: NSNumber
|
||||||
@NSManaged public private(set) var repliesCount: Int
|
@NSManaged public private(set) var repliesCount: NSNumber?
|
||||||
|
|
||||||
@NSManaged public private(set) var url: String?
|
@NSManaged public private(set) var url: String?
|
||||||
@NSManaged public private(set) var inReplyToID: Toot.ID?
|
@NSManaged public private(set) var inReplyToID: Toot.ID?
|
||||||
@NSManaged public private(set) var inReplyToAccountID: MastodonUser.ID?
|
@NSManaged public private(set) var inReplyToAccountID: MastodonUser.ID?
|
||||||
@NSManaged public private(set) var reblog: Toot?
|
|
||||||
@NSManaged public private(set) var language: String? // (ISO 639 Part @NSManaged public private(set) varletter language code)
|
@NSManaged public private(set) var language: String? // (ISO 639 Part 1 two-letter language code)
|
||||||
@NSManaged public private(set) var text: String?
|
@NSManaged public private(set) var text: String?
|
||||||
|
|
||||||
@NSManaged public private(set) var favourited: Bool
|
// many-to-one relastionship
|
||||||
@NSManaged public private(set) var reblogged: Bool
|
@NSManaged public private(set) var favouritedBy: MastodonUser?
|
||||||
@NSManaged public private(set) var muted: Bool
|
@NSManaged public private(set) var rebloggedBy: MastodonUser?
|
||||||
@NSManaged public private(set) var bookmarked: Bool
|
@NSManaged public private(set) var mutedBy: MastodonUser?
|
||||||
@NSManaged public private(set) var pinned: Bool
|
@NSManaged public private(set) var bookmarkedBy: MastodonUser?
|
||||||
|
|
||||||
|
// one-to-one relastionship
|
||||||
|
@NSManaged public private(set) var pinnedBy: MastodonUser?
|
||||||
|
|
||||||
@NSManaged public private(set) var updatedAt: Date
|
@NSManaged public private(set) var updatedAt: Date
|
||||||
@NSManaged public private(set) var deletedAt: Date?
|
@NSManaged public private(set) var deletedAt: Date?
|
||||||
|
|
||||||
|
// one-to-many relationship
|
||||||
|
@NSManaged public private(set) var mentions: Set<Mention>?
|
||||||
|
// one-to-many relationship
|
||||||
|
@NSManaged public private(set) var emojis: Set<Emoji>?
|
||||||
|
// one-to-many relationship
|
||||||
|
@NSManaged public private(set) var tags: Set<Tag>?
|
||||||
|
|
||||||
|
// many-to-one relastionship
|
||||||
|
@NSManaged public private(set) var reblog: Toot?
|
||||||
|
|
||||||
// many-to-one relationship
|
// many-to-one relationship
|
||||||
@NSManaged public private(set) var author: MastodonUser
|
@NSManaged public private(set) var author: MastodonUser
|
||||||
|
|
||||||
|
@ -85,6 +92,9 @@ public extension Toot {
|
||||||
toot.mutableSetValue(forKey: #keyPath(Toot.mentions)).addObjects(from: emojis)
|
toot.mutableSetValue(forKey: #keyPath(Toot.mentions)).addObjects(from: emojis)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let tags = property.tags {
|
||||||
|
toot.mutableSetValue(forKey: #keyPath(Toot.tags)).addObjects(from: tags)
|
||||||
|
}
|
||||||
|
|
||||||
toot.reblogsCount = property.reblogsCount
|
toot.reblogsCount = property.reblogsCount
|
||||||
toot.favouritesCount = property.favouritesCount
|
toot.favouritesCount = property.favouritesCount
|
||||||
|
@ -97,11 +107,23 @@ public extension Toot {
|
||||||
toot.language = property.language
|
toot.language = property.language
|
||||||
toot.text = property.text
|
toot.text = property.text
|
||||||
|
|
||||||
toot.favourited = property.favourited
|
if let favouritedBy = property.favouritedBy {
|
||||||
toot.reblogged = property.reblogged
|
toot.mutableSetValue(forKey: #keyPath(Toot.favouritedBy)).add(favouritedBy)
|
||||||
toot.muted = property.muted
|
}
|
||||||
toot.bookmarked = property.bookmarked
|
if let rebloggedBy = property.rebloggedBy {
|
||||||
toot.pinned = property.pinned
|
toot.mutableSetValue(forKey: #keyPath(Toot.rebloggedBy)).add(rebloggedBy)
|
||||||
|
}
|
||||||
|
if let mutedBy = property.mutedBy {
|
||||||
|
toot.mutableSetValue(forKey: #keyPath(Toot.mutedBy)).add(mutedBy)
|
||||||
|
}
|
||||||
|
if let bookmarkedBy = property.bookmarkedBy {
|
||||||
|
toot.mutableSetValue(forKey: #keyPath(Toot.bookmarkedBy)).add(bookmarkedBy)
|
||||||
|
}
|
||||||
|
if let pinnedBy = property.pinnedBy {
|
||||||
|
toot.mutableSetValue(forKey: #keyPath(Toot.pinnedBy))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
toot.updatedAt = property.updatedAt
|
toot.updatedAt = property.updatedAt
|
||||||
toot.deletedAt = property.deletedAt
|
toot.deletedAt = property.deletedAt
|
||||||
toot.author = property.author
|
toot.author = property.author
|
||||||
|
@ -125,20 +147,21 @@ public extension Toot {
|
||||||
spoilerText: String?,
|
spoilerText: String?,
|
||||||
mentions: [Mention]?,
|
mentions: [Mention]?,
|
||||||
emojis: [Emoji]?,
|
emojis: [Emoji]?,
|
||||||
reblogsCount: Int,
|
tags: [Tag]?,
|
||||||
favouritesCount: Int,
|
reblogsCount: NSNumber,
|
||||||
repliesCount: Int,
|
favouritesCount: NSNumber,
|
||||||
|
repliesCount: NSNumber?,
|
||||||
url: String?,
|
url: String?,
|
||||||
inReplyToID: Toot.ID?,
|
inReplyToID: Toot.ID?,
|
||||||
inReplyToAccountID: MastodonUser.ID?,
|
inReplyToAccountID: MastodonUser.ID?,
|
||||||
reblog: Toot?,
|
reblog: Toot?,
|
||||||
language: String?,
|
language: String?,
|
||||||
text: String?,
|
text: String?,
|
||||||
favourited: Bool,
|
favouritedBy: MastodonUser?,
|
||||||
reblogged: Bool,
|
rebloggedBy: MastodonUser?,
|
||||||
muted: Bool,
|
mutedBy: MastodonUser?,
|
||||||
bookmarked: Bool,
|
bookmarkedBy: MastodonUser?,
|
||||||
pinned: Bool,
|
pinnedBy: MastodonUser?,
|
||||||
updatedAt: Date,
|
updatedAt: Date,
|
||||||
deletedAt: Date?,
|
deletedAt: Date?,
|
||||||
author: MastodonUser,
|
author: MastodonUser,
|
||||||
|
@ -155,6 +178,7 @@ public extension Toot {
|
||||||
self.spoilerText = spoilerText
|
self.spoilerText = spoilerText
|
||||||
self.mentions = mentions
|
self.mentions = mentions
|
||||||
self.emojis = emojis
|
self.emojis = emojis
|
||||||
|
self.tags = tags
|
||||||
self.reblogsCount = reblogsCount
|
self.reblogsCount = reblogsCount
|
||||||
self.favouritesCount = favouritesCount
|
self.favouritesCount = favouritesCount
|
||||||
self.repliesCount = repliesCount
|
self.repliesCount = repliesCount
|
||||||
|
@ -164,11 +188,11 @@ public extension Toot {
|
||||||
self.reblog = reblog
|
self.reblog = reblog
|
||||||
self.language = language
|
self.language = language
|
||||||
self.text = text
|
self.text = text
|
||||||
self.favourited = favourited
|
self.favouritedBy = favouritedBy
|
||||||
self.reblogged = reblogged
|
self.rebloggedBy = rebloggedBy
|
||||||
self.muted = muted
|
self.mutedBy = mutedBy
|
||||||
self.bookmarked = bookmarked
|
self.bookmarkedBy = bookmarkedBy
|
||||||
self.pinned = pinned
|
self.pinnedBy = pinnedBy
|
||||||
self.updatedAt = updatedAt
|
self.updatedAt = updatedAt
|
||||||
self.deletedAt = deletedAt
|
self.deletedAt = deletedAt
|
||||||
self.author = author
|
self.author = author
|
||||||
|
@ -189,22 +213,24 @@ public extension Toot {
|
||||||
|
|
||||||
public let mentions: [Mention]?
|
public let mentions: [Mention]?
|
||||||
public let emojis: [Emoji]?
|
public let emojis: [Emoji]?
|
||||||
public let reblogsCount: Int
|
public let tags: [Tag]?
|
||||||
public let favouritesCount: Int
|
public let reblogsCount: NSNumber
|
||||||
public let repliesCount: Int
|
public let favouritesCount: NSNumber
|
||||||
|
public let repliesCount: NSNumber?
|
||||||
|
|
||||||
public let url: String?
|
public let url: String?
|
||||||
public let inReplyToID: Toot.ID?
|
public let inReplyToID: Toot.ID?
|
||||||
public let inReplyToAccountID: MastodonUser.ID?
|
public let inReplyToAccountID: MastodonUser.ID?
|
||||||
public let reblog: Toot?
|
public let reblog: Toot?
|
||||||
public let language: String? // (ISO 639 Part @NSManaged public private(set) varletter language public let
|
public let language: String? // (ISO 639 Part @1 two-letter language code)
|
||||||
public let text: String?
|
public let text: String?
|
||||||
|
|
||||||
public let favourited: Bool
|
public let favouritedBy: MastodonUser?
|
||||||
public let reblogged: Bool
|
public let rebloggedBy: MastodonUser?
|
||||||
public let muted: Bool
|
public let mutedBy: MastodonUser?
|
||||||
public let bookmarked: Bool
|
public let bookmarkedBy: MastodonUser?
|
||||||
public let pinned: Bool
|
public let pinnedBy: MastodonUser?
|
||||||
|
|
||||||
public let updatedAt: Date
|
public let updatedAt: Date
|
||||||
public let deletedAt: Date?
|
public let deletedAt: Date?
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ extension TimelineSection {
|
||||||
// configure cell
|
// configure cell
|
||||||
managedObjectContext.performAndWait {
|
managedObjectContext.performAndWait {
|
||||||
let toot = managedObjectContext.object(with: objectID) as! Toot
|
let toot = managedObjectContext.object(with: objectID) as! Toot
|
||||||
TimelineSection.configure(cell: cell, toot: toot)
|
TimelineSection.configure(cell: cell,timestampUpdatePublisher: timestampUpdatePublisher, toot: toot)
|
||||||
}
|
}
|
||||||
cell.delegate = timelinePostTableViewCellDelegate
|
cell.delegate = timelinePostTableViewCellDelegate
|
||||||
return cell
|
return cell
|
||||||
|
@ -43,6 +43,7 @@ extension TimelineSection {
|
||||||
|
|
||||||
static func configure(
|
static func configure(
|
||||||
cell: TimelinePostTableViewCell,
|
cell: TimelinePostTableViewCell,
|
||||||
|
timestampUpdatePublisher: AnyPublisher<Date, Never>,
|
||||||
toot: Toot
|
toot: Toot
|
||||||
) {
|
) {
|
||||||
// set name username avatar
|
// set name username avatar
|
||||||
|
@ -56,8 +57,12 @@ extension TimelineSection {
|
||||||
// set text
|
// set text
|
||||||
cell.timelinePostView.activeTextLabel.config(content: toot.content)
|
cell.timelinePostView.activeTextLabel.config(content: toot.content)
|
||||||
// set date
|
// set date
|
||||||
let createdAt = toot.createdAt
|
let createdAt = (toot.reblog ?? toot).createdAt
|
||||||
cell.timelinePostView.dateLabel.text = createdAt.shortTimeAgoSinceNow
|
timestampUpdatePublisher
|
||||||
|
.sink { _ in
|
||||||
|
cell.timelinePostView.dateLabel.text = createdAt.shortTimeAgoSinceNow
|
||||||
|
}
|
||||||
|
.store(in: &cell.disposeBag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,10 @@ extension PublicTimelineViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
tableView.translatesAutoresizingMaskIntoConstraints = false
|
tableView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
view.addSubview(tableView)
|
|
||||||
tableView.backgroundColor = Asset.Colors.tootDark.color
|
tableView.backgroundColor = Asset.Colors.tootDark.color
|
||||||
|
view.addSubview(tableView)
|
||||||
|
view.backgroundColor = Asset.Colors.tootDark.color
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
tableView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
|
|
|
@ -31,7 +31,14 @@ extension APIService.Persist {
|
||||||
Mention.insert(into: managedObjectContext, property: Mention.Property(id: mention.id, username: mention.username, acct: mention.acct, url: mention.url))
|
Mention.insert(into: managedObjectContext, property: Mention.Property(id: mention.id, username: mention.username, acct: mention.acct, url: mention.url))
|
||||||
})
|
})
|
||||||
let emojis = $0.emojis?.compactMap({ (emoji) -> Emoji in
|
let emojis = $0.emojis?.compactMap({ (emoji) -> Emoji in
|
||||||
Emoji.insert(into: managedObjectContext, property: Emoji.Property(shortcode: emoji.shortcode, url: emoji.url, staticURL: emoji.staticURL, visibleInPicker: emoji.visibleInPicker))
|
Emoji.insert(into: managedObjectContext, property: Emoji.Property(shortcode: emoji.shortcode, url: emoji.url, staticURL: emoji.staticURL, visibleInPicker: emoji.visibleInPicker, category: emoji.category))
|
||||||
|
})
|
||||||
|
|
||||||
|
let tags = $0.tags?.compactMap({ (tag) -> Tag in
|
||||||
|
let histories = tag.history?.compactMap({ (history) -> History in
|
||||||
|
History.insert(into: managedObjectContext, property: History.Property(day: history.day, uses: history.uses, accounts: history.accounts))
|
||||||
|
})
|
||||||
|
return Tag.insert(into: managedObjectContext, property: Tag.Property(name: tag.name, url: tag.url, histories: histories))
|
||||||
})
|
})
|
||||||
let tootProperty = Toot.Property(
|
let tootProperty = Toot.Property(
|
||||||
domain: domain,
|
domain: domain,
|
||||||
|
@ -44,20 +51,21 @@ extension APIService.Persist {
|
||||||
spoilerText: $0.spoilerText,
|
spoilerText: $0.spoilerText,
|
||||||
mentions: metions,
|
mentions: metions,
|
||||||
emojis: emojis,
|
emojis: emojis,
|
||||||
reblogsCount: $0.reblogsCount,
|
tags: tags,
|
||||||
favouritesCount: $0.favouritesCount,
|
reblogsCount: NSNumber(value: $0.reblogsCount),
|
||||||
repliesCount: $0.repliesCount ?? 0,
|
favouritesCount: NSNumber(value: $0.favouritesCount),
|
||||||
|
repliesCount: ($0.repliesCount != nil) ? NSNumber(value: $0.repliesCount!) : nil,
|
||||||
url: $0.uri,
|
url: $0.uri,
|
||||||
inReplyToID: $0.inReplyToID,
|
inReplyToID: $0.inReplyToID,
|
||||||
inReplyToAccountID: $0.inReplyToAccountID,
|
inReplyToAccountID: $0.inReplyToAccountID,
|
||||||
reblog: nil, //TODO 需要递归调用
|
reblog: nil, //TODO need fix
|
||||||
language: $0.language,
|
language: $0.language,
|
||||||
text: $0.text,
|
text: $0.text,
|
||||||
favourited: $0.favourited ?? false,
|
favouritedBy: ($0.favourited ?? false) ? author : nil,
|
||||||
reblogged: $0.reblogged ?? false,
|
rebloggedBy: ($0.reblogged ?? false) ? author : nil,
|
||||||
muted: $0.muted ?? false,
|
mutedBy: ($0.muted ?? false) ? author : nil,
|
||||||
bookmarked: $0.bookmarked ?? false,
|
bookmarkedBy: ($0.bookmarked ?? false) ? author : nil,
|
||||||
pinned: $0.pinned ?? false,
|
pinnedBy: ($0.pinned ?? false) ? author : nil,
|
||||||
updatedAt: response.networkDate,
|
updatedAt: response.networkDate,
|
||||||
deletedAt: nil,
|
deletedAt: nil,
|
||||||
author: author,
|
author: author,
|
||||||
|
|
|
@ -34,7 +34,7 @@ extension Mastodon.Entity {
|
||||||
public let displayName: String
|
public let displayName: String
|
||||||
public let note: String
|
public let note: String
|
||||||
public let avatar: String
|
public let avatar: String
|
||||||
public let avatarStatic: String
|
public let avatarStatic: String?
|
||||||
public let header: String
|
public let header: String
|
||||||
public let headerStatic: String
|
public let headerStatic: String
|
||||||
public let locked: Bool
|
public let locked: Bool
|
||||||
|
|
Loading…
Reference in New Issue