diff --git a/Planet/Entities/DraftModel.swift b/Planet/Entities/DraftModel.swift index f8e1068e..e882a71c 100644 --- a/Planet/Entities/DraftModel.swift +++ b/Planet/Entities/DraftModel.swift @@ -438,7 +438,7 @@ class DraftModel: Identifiable, Equatable, Hashable, Codable, ObservableObject { article.attachments = currentAttachments article.heroImage = heroImage article.tags = tags - article.cids = article.getCIDs() + article.cids = article.getCIDs(for: currentAttachments) article.videoFilename = videoFilename article.audioFilename = audioFilename if let contentHTML = CMarkRenderer.renderMarkdownHTML(markdown: article.content), diff --git a/Planet/Entities/MyArticleModel+Save.swift b/Planet/Entities/MyArticleModel+Save.swift index 2d2d0977..96fe8e78 100644 --- a/Planet/Entities/MyArticleModel+Save.swift +++ b/Planet/Entities/MyArticleModel+Save.swift @@ -147,10 +147,10 @@ extension MyArticleModel { } /// Get CIDs of all attachments - func getCIDs() -> [String: String] { - if let attachments = self.attachments, attachments.count > 0 { + func getCIDs(for attachmentsToProcess: [String]) -> [String: String] { + if attachmentsToProcess.count > 0 { var cids: [String: String] = [:] - for attachment in attachments { + for attachment in attachmentsToProcess { if let attachmentURL = getAttachmentURL(name: attachment) { if let attachmentCID = try? IPFSDaemon.shared.getFileCIDv0(url: attachmentURL) { debugPrint("CID for \(attachment): \(attachmentCID)") diff --git a/Planet/Entities/MyArticleModel+SavePublic.swift b/Planet/Entities/MyArticleModel+SavePublic.swift index 13a55c43..31c13f3a 100644 --- a/Planet/Entities/MyArticleModel+SavePublic.swift +++ b/Planet/Entities/MyArticleModel+SavePublic.swift @@ -93,10 +93,17 @@ extension MyArticleModel { } } } + var attachmentsToProcess: [String] = [] + if let attachments = self.attachments { + attachmentsToProcess = attachments + } + if attachmentsToProcess.count == 0, self.planet.templateName == "Croptop" { + attachmentsToProcess = ["_cover.png"] + } var attachmentCIDs: [String: String] = self.cids ?? [:] let needsToUpdateCIDs = { if let cids = self.cids, cids.count > 0 { - for attachment in self.attachments ?? [] { + for attachment in attachmentsToProcess { if cids[attachment] == nil { debugPrint( "CID Update for \(self.title): NEEDED because \(attachment) is missing" @@ -112,7 +119,7 @@ extension MyArticleModel { } return false } - if self.attachments?.count ?? 0 > 0 { + if attachmentsToProcess.count > 0 { debugPrint("CID Update for \(self.title): NEEDED because cids is nil") return true } @@ -120,7 +127,7 @@ extension MyArticleModel { }() if needsToUpdateCIDs { debugPrint("CID Update for \(self.title): NEEDED") - attachmentCIDs = getCIDs() + attachmentCIDs = getCIDs(for: attachmentsToProcess) self.cids = attachmentCIDs try? self.save() } @@ -206,7 +213,7 @@ extension MyArticleModel { image: "https://ipfs.io/ipfs/\(imageCID)", external_url: (self.externalLink ?? self.browserURL?.absoluteString) ?? "", mimeType: self.getAttachmentMimeType(name: firstKey), - animation_url: "https://ipfs.io/ipfs/\(animationCID)" ?? nil, + animation_url: animationCID != nil ? "https://ipfs.io/ipfs/\(animationCID)" : nil, attributes: attributes ) let nftData = try JSONEncoder.shared.encode(nft) diff --git a/Planet/versioning.xcconfig b/Planet/versioning.xcconfig index 06e1c341..50f73894 100644 --- a/Planet/versioning.xcconfig +++ b/Planet/versioning.xcconfig @@ -1 +1 @@ -CURRENT_PROJECT_VERSION = 1862 +CURRENT_PROJECT_VERSION = 1863 diff --git a/PlanetLite/AppSidebarItemView.swift b/PlanetLite/AppSidebarItemView.swift index a5b6127a..414717d9 100644 --- a/PlanetLite/AppSidebarItemView.swift +++ b/PlanetLite/AppSidebarItemView.swift @@ -133,7 +133,7 @@ struct AppSidebarItemView: View { Button { openVSCode(template) } label: { - Image(systemName: "curlybraces") + Image(systemName: "chevron.left.slash.chevron.right") Text("Open Template in VSCode") } }