diff --git a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
index 1c83fcaee..d54c086ce 100644
--- a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
+++ b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
@@ -123,21 +123,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -182,7 +167,6 @@
-
diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift
index 1593236f8..cb44c458a 100644
--- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift
+++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift
@@ -72,7 +72,6 @@ final public class MastodonUser: NSManagedObject {
@NSManaged public private(set) var reblogged: Set
@NSManaged public private(set) var muted: Set
@NSManaged public private(set) var bookmarked: Set
- @NSManaged public private(set) var votePolls: Set
// relationships
@NSManaged public private(set) var following: Set
@NSManaged public private(set) var followingBy: Set
diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Poll.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Poll.swift
deleted file mode 100644
index 81f71437c..000000000
--- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Poll.swift
+++ /dev/null
@@ -1,316 +0,0 @@
-//
-// Poll.swift
-// CoreDataStack
-//
-// Created by MainasuK Cirno on 2021-3-2.
-//
-
-import Foundation
-import CoreData
-
-public final class PollLegacy: NSManagedObject {
- public typealias ID = String
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var domain: String
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var id: ID
-
- // sourcery: autoUpdatableObject, autoGenerateProperty
- @NSManaged public private(set) var expiresAt: Date?
- // sourcery: autoUpdatableObject, autoGenerateProperty
- @NSManaged public private(set) var expired: Bool
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var multiple: Bool
-
- // sourcery: autoUpdatableObject, autoGenerateProperty
- @NSManaged public private(set) var votesCount: Int64
- // sourcery: autoUpdatableObject, autoGenerateProperty
- @NSManaged public private(set) var votersCount: Int64
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var createdAt: Date
- // sourcery: autoUpdatableObject, autoGenerateProperty
- @NSManaged public private(set) var updatedAt: Date
-
- // sourcery: autoUpdatableObject
- @NSManaged public private(set) var isVoting: Bool
-
- // one-to-one relationship
- @NSManaged public private(set) var status: Status?
-
- // many-to-many relationship
- @NSManaged public private(set) var votedBy: Set?
-}
-
-extension PollLegacy {
-
- @discardableResult
- public static func insert(
- into context: NSManagedObjectContext,
- property: Property
- ) -> PollLegacy {
- let object: PollLegacy = context.insertObject()
-
- object.configure(property: property)
-
- return object
- }
-
-}
-
-extension PollLegacy: Managed {
- public static var defaultSortDescriptors: [NSSortDescriptor] {
- return [NSSortDescriptor(keyPath: \PollLegacy.createdAt, ascending: false)]
- }
-}
-
-extension PollLegacy {
- static func predicate(domain: String) -> NSPredicate {
- return NSPredicate(format: "%K == %@", #keyPath(PollLegacy.domain), domain)
- }
-
- static func predicate(id: ID) -> NSPredicate {
- return NSPredicate(format: "%K == %@", #keyPath(PollLegacy.id), id)
- }
-
- static func predicate(ids: [ID]) -> NSPredicate {
- return NSPredicate(format: "%K IN %@", #keyPath(PollLegacy.id), ids)
- }
-
- public static func predicate(domain: String, id: ID) -> NSPredicate {
- return NSCompoundPredicate(andPredicateWithSubpredicates: [
- predicate(domain: domain),
- predicate(id: id)
- ])
- }
-
- public static func predicate(domain: String, ids: [ID]) -> NSPredicate {
- return NSCompoundPredicate(andPredicateWithSubpredicates: [
- predicate(domain: domain),
- predicate(ids: ids)
- ])
- }
-}
-
-//extension Poll {
-//
-// public override func awakeFromInsert() {
-// super.awakeFromInsert()
-// setPrimitiveValue(Date(), forKey: #keyPath(Poll.createdAt))
-// }
-//
-// @discardableResult
-// public static func insert(
-// into context: NSManagedObjectContext,
-// property: Property,
-// votedBy: MastodonUser?,
-// options: [PollOption]
-// ) -> Poll {
-// let poll: Poll = context.insertObject()
-//
-// poll.id = property.id
-// poll.expiresAt = property.expiresAt
-// poll.expired = property.expired
-// poll.multiple = property.multiple
-// poll.votesCount = property.votesCount
-// poll.votersCount = property.votersCount
-//
-//
-// poll.updatedAt = property.networkDate
-//
-// if let votedBy = votedBy {
-// poll.mutableSetValue(forKey: #keyPath(Poll.votedBy)).add(votedBy)
-// }
-// poll.mutableSetValue(forKey: #keyPath(Poll.options)).addObjects(from: options)
-//
-// return poll
-// }
-//
-// public func update(expiresAt: Date?) {
-// if self.expiresAt != expiresAt {
-// self.expiresAt = expiresAt
-// }
-// }
-//
-// public func update(expired: Bool) {
-// if self.expired != expired {
-// self.expired = expired
-// }
-// }
-//
-// public func update(votesCount: Int) {
-// if self.votesCount.intValue != votesCount {
-// self.votesCount = NSNumber(value: votesCount)
-// }
-// }
-//
-// public func update(votersCount: Int?) {
-// if self.votersCount?.intValue != votersCount {
-// self.votersCount = votersCount.flatMap { NSNumber(value: $0) }
-// }
-// }
-//
-// public func update(voted: Bool, by: MastodonUser) {
-// if voted {
-// if !(votedBy ?? Set()).contains(by) {
-// mutableSetValue(forKey: #keyPath(Poll.votedBy)).add(by)
-// }
-// } else {
-// if (votedBy ?? Set()).contains(by) {
-// mutableSetValue(forKey: #keyPath(Poll.votedBy)).remove(by)
-// }
-// }
-// }
-//
-// public func didUpdate(at networkDate: Date) {
-// self.updatedAt = networkDate
-// }
-//
-//}
-
-//extension Poll {
-// public struct Property {
-// public let id: ID
-// public let expiresAt: Date?
-// public let expired: Bool
-// public let multiple: Bool
-// public let votesCount: NSNumber
-// public let votersCount: NSNumber?
-//
-// public let networkDate: Date
-//
-// public init(
-// id: Poll.ID,
-// expiresAt: Date?,
-// expired: Bool,
-// multiple: Bool,
-// votesCount: Int,
-// votersCount: Int?,
-// networkDate: Date
-// ) {
-// self.id = id
-// self.expiresAt = expiresAt
-// self.expired = expired
-// self.multiple = multiple
-// self.votesCount = NSNumber(value: votesCount)
-// self.votersCount = votersCount.flatMap { NSNumber(value: $0) }
-// self.networkDate = networkDate
-// }
-// }
-//}
-
-// MARK: - AutoGenerateProperty
-extension PollLegacy: AutoGenerateProperty {
- // sourcery:inline:Poll.AutoGenerateProperty
-
- // Generated using Sourcery
- // DO NOT EDIT
- public struct Property {
- public let domain: String
- public let id: ID
- public let expiresAt: Date?
- public let expired: Bool
- public let multiple: Bool
- public let votesCount: Int64
- public let votersCount: Int64
- public let createdAt: Date
- public let updatedAt: Date
-
- public init(
- domain: String,
- id: ID,
- expiresAt: Date?,
- expired: Bool,
- multiple: Bool,
- votesCount: Int64,
- votersCount: Int64,
- createdAt: Date,
- updatedAt: Date
- ) {
- self.domain = domain
- self.id = id
- self.expiresAt = expiresAt
- self.expired = expired
- self.multiple = multiple
- self.votesCount = votesCount
- self.votersCount = votersCount
- self.createdAt = createdAt
- self.updatedAt = updatedAt
- }
- }
-
- public func configure(property: Property) {
- self.domain = property.domain
- self.id = property.id
- self.expiresAt = property.expiresAt
- self.expired = property.expired
- self.multiple = property.multiple
- self.votesCount = property.votesCount
- self.votersCount = property.votersCount
- self.createdAt = property.createdAt
- self.updatedAt = property.updatedAt
- }
-
- public func update(property: Property) {
- update(expiresAt: property.expiresAt)
- update(expired: property.expired)
- update(votesCount: property.votesCount)
- update(votersCount: property.votersCount)
- update(updatedAt: property.updatedAt)
- }
- // sourcery:end
-
-}
-
-// MARK: - AutoUpdatableObject
-extension PollLegacy: AutoUpdatableObject {
- // sourcery:inline:Poll.AutoUpdatableObject
-
- // Generated using Sourcery
- // DO NOT EDIT
- public func update(expiresAt: Date?) {
- if self.expiresAt != expiresAt {
- self.expiresAt = expiresAt
- }
- }
- public func update(expired: Bool) {
- if self.expired != expired {
- self.expired = expired
- }
- }
- public func update(votesCount: Int64) {
- if self.votesCount != votesCount {
- self.votesCount = votesCount
- }
- }
- public func update(votersCount: Int64) {
- if self.votersCount != votersCount {
- self.votersCount = votersCount
- }
- }
- public func update(updatedAt: Date) {
- if self.updatedAt != updatedAt {
- self.updatedAt = updatedAt
- }
- }
- public func update(isVoting: Bool) {
- if self.isVoting != isVoting {
- self.isVoting = isVoting
- }
- }
- // sourcery:end
-
- public func update(voted: Bool, by: MastodonUser) {
- if voted {
- if !(votedBy ?? Set()).contains(by) {
- mutableSetValue(forKey: #keyPath(PollLegacy.votedBy)).add(by)
- }
- } else {
- if (votedBy ?? Set()).contains(by) {
- mutableSetValue(forKey: #keyPath(PollLegacy.votedBy)).remove(by)
- }
- }
- }
-}
diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
index ba30aa0eb..dfb33fc1a 100644
--- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
+++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
@@ -77,8 +77,6 @@ public final class Status: NSManagedObject {
// sourcery: autoUpdatableObject
@NSManaged public private(set) var replyTo: Status?
- // sourcery: autoGenerateRelationship
- @NSManaged public private(set) var poll: PollLegacy?
// sourcery: autoGenerateRelationship
@NSManaged public private(set) var card: Card?
@@ -379,18 +377,15 @@ extension Status: AutoGenerateRelationship {
public struct Relationship {
public let application: Application?
public let reblog: Status?
- public let poll: PollLegacy?
public let card: Card?
public init(
application: Application?,
reblog: Status?,
- poll: PollLegacy?,
card: Card?
) {
self.application = application
self.reblog = reblog
- self.poll = poll
self.card = card
}
}
@@ -398,7 +393,6 @@ extension Status: AutoGenerateRelationship {
public func configure(relationship: Relationship) {
self.application = relationship.application
self.reblog = relationship.reblog
- self.poll = relationship.poll
self.card = relationship.card
}
// sourcery:end
diff --git a/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/Poll+Property.swift b/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/Poll+Property.swift
deleted file mode 100644
index 4022b1176..000000000
--- a/MastodonSDK/Sources/MastodonCore/Extension/CoreDataStack/Poll+Property.swift
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// MastodonPoll.swift
-//
-//
-// Created by MainasuK on 2021-12-9.
-//
-
-import Foundation
-import CoreDataStack
-import MastodonSDK
-
-extension PollLegacy.Property {
- public init(
- entity: Mastodon.Entity.Poll,
- domain: String,
- networkDate: Date
- ) {
- self.init(
- domain: domain,
- id: entity.id,
- expiresAt: entity.expiresAt,
- expired: entity.expired,
- multiple: entity.multiple,
- votesCount: Int64(entity.votesCount),
- votersCount: Int64(entity.votersCount ?? 0),
- createdAt: networkDate,
- updatedAt: networkDate
- )
- }
-}
diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
index de4a5831c..b42b69016 100644
--- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
+++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
@@ -79,7 +79,6 @@ extension Persistence.Status {
isNewInsertion: false
)
} else {
- var poll: PollLegacy? = nil
let card = createCard(in: managedObjectContext, context: context)
@@ -88,7 +87,6 @@ extension Persistence.Status {
let relationship = Status.Relationship(
application: application,
reblog: reblog,
- poll: poll,
card: card
)
let status = create(