DraftsModel.swift (957B)
1 // 2 // DraftsModel.swift 3 // damus 4 // 5 // Created by Terry Yiu on 2/12/23. 6 // 7 8 import Foundation 9 10 class DraftArtifacts: Equatable { 11 var content: NSMutableAttributedString 12 var media: [UploadedMedia] 13 14 init(content: NSMutableAttributedString = NSMutableAttributedString(string: ""), media: [UploadedMedia] = []) { 15 self.content = content 16 self.media = media 17 } 18 19 static func == (lhs: DraftArtifacts, rhs: DraftArtifacts) -> Bool { 20 return ( 21 lhs.media == rhs.media && 22 lhs.content.string == rhs.content.string // Comparing the text content is not perfect but acceptable in this case because attributes for our post editor are determined purely from text content 23 ) 24 } 25 } 26 27 class Drafts: ObservableObject { 28 @Published var post: DraftArtifacts? = nil 29 @Published var replies: [NostrEvent: DraftArtifacts] = [:] 30 @Published var quotes: [NostrEvent: DraftArtifacts] = [:] 31 }