diff --git a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
index d54c086ce..eec0c33ce 100644
--- a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
+++ b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents
@@ -7,23 +7,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -162,7 +145,6 @@
-
diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Card.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Card.swift
deleted file mode 100644
index 64f5e2120..000000000
--- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Card.swift
+++ /dev/null
@@ -1,180 +0,0 @@
-//
-// Card.swift
-// CoreDataStack
-//
-// Created by Kyle Bashour on 11/23/22.
-//
-
-import Foundation
-import CoreData
-
-public final class Card: NSManagedObject {
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var urlRaw: String
- public var url: URL? {
- URL(string: urlRaw)
- }
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var title: String
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var desc: String
-
- @NSManaged public private(set) var typeRaw: String
- // sourcery: autoGenerateProperty
- public var type: MastodonCardType {
- get { MastodonCardType(rawValue: typeRaw) }
- set { typeRaw = newValue.rawValue }
- }
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var authorName: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var authorURLRaw: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var providerName: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var providerURLRaw: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var width: Int64
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var height: Int64
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var image: String?
- public var imageURL: URL? {
- image.flatMap(URL.init)
- }
-
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var embedURLRaw: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var blurhash: String?
- // sourcery: autoGenerateProperty
- @NSManaged public private(set) var html: String?
-
- // sourcery: autoGenerateRelationship
- @NSManaged public private(set) var status: Status
-}
-
-extension Card {
-
- @discardableResult
- public static func insert(
- into context: NSManagedObjectContext,
- property: Property
- ) -> Card {
- let object: Card = context.insertObject()
-
- object.configure(property: property)
-
- return object
- }
-
-}
-
-extension Card: Managed {
- public static var defaultSortDescriptors: [NSSortDescriptor] {
- return []
- }
-}
-
-// MARK: - AutoGenerateProperty
-extension Card: AutoGenerateProperty {
- // sourcery:inline:Card.AutoGenerateProperty
-
- // Generated using Sourcery
- // DO NOT EDIT
- public struct Property {
- public let urlRaw: String
- public let title: String
- public let desc: String
- public let type: MastodonCardType
- public let authorName: String?
- public let authorURLRaw: String?
- public let providerName: String?
- public let providerURLRaw: String?
- public let width: Int64
- public let height: Int64
- public let image: String?
- public let embedURLRaw: String?
- public let blurhash: String?
- public let html: String?
-
- public init(
- urlRaw: String,
- title: String,
- desc: String,
- type: MastodonCardType,
- authorName: String?,
- authorURLRaw: String?,
- providerName: String?,
- providerURLRaw: String?,
- width: Int64,
- height: Int64,
- image: String?,
- embedURLRaw: String?,
- blurhash: String?,
- html: String?
- ) {
- self.urlRaw = urlRaw
- self.title = title
- self.desc = desc
- self.type = type
- self.authorName = authorName
- self.authorURLRaw = authorURLRaw
- self.providerName = providerName
- self.providerURLRaw = providerURLRaw
- self.width = width
- self.height = height
- self.image = image
- self.embedURLRaw = embedURLRaw
- self.blurhash = blurhash
- self.html = html
- }
- }
-
- public func configure(property: Property) {
- self.urlRaw = property.urlRaw
- self.title = property.title
- self.desc = property.desc
- self.type = property.type
- self.authorName = property.authorName
- self.authorURLRaw = property.authorURLRaw
- self.providerName = property.providerName
- self.providerURLRaw = property.providerURLRaw
- self.width = property.width
- self.height = property.height
- self.image = property.image
- self.embedURLRaw = property.embedURLRaw
- self.blurhash = property.blurhash
- self.html = property.html
- }
-
- public func update(property: Property) {
- }
-
- // sourcery:end
-}
-
-// MARK: - AutoGenerateRelationship
-extension Card: AutoGenerateRelationship {
- // sourcery:inline:Card.AutoGenerateRelationship
-
- // Generated using Sourcery
- // DO NOT EDIT
- public struct Relationship {
- public let status: Status
-
- public init(
- status: Status
- ) {
- self.status = status
- }
- }
-
- public func configure(relationship: Relationship) {
- self.status = relationship.status
- }
-
- // sourcery:end
-}
diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
index dfb33fc1a..f6018c5d4 100644
--- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
+++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/Status.swift
@@ -77,9 +77,6 @@ public final class Status: NSManagedObject {
// sourcery: autoUpdatableObject
@NSManaged public private(set) var replyTo: Status?
- // sourcery: autoGenerateRelationship
- @NSManaged public private(set) var card: Card?
-
// one-to-many relationship
@NSManaged public private(set) var feeds: Set
@@ -377,23 +374,19 @@ extension Status: AutoGenerateRelationship {
public struct Relationship {
public let application: Application?
public let reblog: Status?
- public let card: Card?
public init(
application: Application?,
- reblog: Status?,
- card: Card?
- ) {
+ reblog: Status?
+ ) {
self.application = application
self.reblog = reblog
- self.card = card
}
}
public func configure(relationship: Relationship) {
self.application = relationship.application
self.reblog = relationship.reblog
- self.card = relationship.card
}
// sourcery:end
}
diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift
deleted file mode 100644
index e390d8e35..000000000
--- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Card.swift
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// Persistence+Card.swift
-//
-//
-// Created by MainasuK on 2021-12-9.
-//
-
-import CoreData
-import CoreDataStack
-import Foundation
-import MastodonSDK
-
-extension Persistence.Card {
-
- public struct PersistContext {
- public let domain: String
- public let entity: Mastodon.Entity.Card
- public let me: MastodonUser?
- public init(
- domain: String,
- entity: Mastodon.Entity.Card,
- me: MastodonUser?
- ) {
- self.domain = domain
- self.entity = entity
- self.me = me
- }
- }
-
- public struct PersistResult {
- public let card: Card
- public let isNewInsertion: Bool
-
- public init(
- card: Card,
- isNewInsertion: Bool
- ) {
- self.card = card
- self.isNewInsertion = isNewInsertion
- }
- }
-
- public static func create(
- in managedObjectContext: NSManagedObjectContext,
- context: PersistContext
- ) -> PersistResult {
- var type: MastodonCardType {
- switch context.entity.type {
- case .link: return .link
- case .photo: return .photo
- case .video: return .video
- case .rich: return ._other(context.entity.type.rawValue)
- case ._other(let rawValue): return ._other(rawValue)
- }
- }
-
- let property = Card.Property(
- urlRaw: context.entity.url,
- title: context.entity.title,
- desc: context.entity.description,
- type: type,
- authorName: context.entity.authorName,
- authorURLRaw: context.entity.authorURL,
- providerName: context.entity.providerName,
- providerURLRaw: context.entity.providerURL,
- width: Int64(context.entity.width ?? 0),
- height: Int64(context.entity.height ?? 0),
- image: context.entity.image,
- embedURLRaw: context.entity.embedURL,
- blurhash: context.entity.blurhash,
- html: context.entity.html.flatMap { $0.isEmpty ? nil : $0 }
- )
-
- let card = Card.insert(
- into: managedObjectContext,
- property: property
- )
-
- return PersistResult(
- card: card,
- isNewInsertion: true
- )
- }
-
-}
diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
index b42b69016..bdbb4441d 100644
--- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
+++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence+Status.swift
@@ -79,15 +79,11 @@ extension Persistence.Status {
isNewInsertion: false
)
} else {
-
- let card = createCard(in: managedObjectContext, context: context)
-
let application: Application? = createApplication(in: managedObjectContext, context: .init(entity: context.entity))
let relationship = Status.Relationship(
application: application,
- reblog: reblog,
- card: card
+ reblog: reblog
)
let status = create(
in: managedObjectContext,
@@ -156,28 +152,6 @@ extension Persistence.Status {
networkDate: context.networkDate
)
status.update(property: property)
-
- if status.card == nil, context.entity.card != nil {
- let card = createCard(in: managedObjectContext, context: context)
- let relationship = Card.Relationship(status: status)
- card?.configure(relationship: relationship)
- }
- }
-
- private static func createCard(
- in managedObjectContext: NSManagedObjectContext,
- context: PersistContext
- ) -> Card? {
- guard let entity = context.entity.card else { return nil }
- let result = Persistence.Card.create(
- in: managedObjectContext,
- context: Persistence.Card.PersistContext(
- domain: context.domain,
- entity: entity,
- me: context.me
- )
- )
- return result.card
}
private static func createApplication(
diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift
index 4b1ca82a4..0c2cf42fe 100644
--- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift
+++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift
@@ -45,7 +45,6 @@ public enum Persistence {
extension Persistence {
public enum MastodonUser { }
public enum Status { }
- public enum Card { }
public enum SearchHistory { }
public enum Notification { }
}
diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
index c096428a5..2796549c2 100644
--- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
+++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
@@ -326,18 +326,6 @@ private extension StatusCardControl {
}
}
-private extension Card {
- var layout: StatusCardControl.Layout {
- var aspectRatio = CGFloat(width) / CGFloat(height)
- if !aspectRatio.isFinite {
- aspectRatio = 1
- }
- return (abs(aspectRatio - 1) < 0.05 || image == nil) && html == nil
- ? .compact
- : .large(aspectRatio: aspectRatio)
- }
-}
-
private extension Mastodon.Entity.Card {
var layout: StatusCardControl.Layout {
var aspectRatio = CGFloat(width ?? 1) / CGFloat(height ?? 1)