Skip to content

Commit

Permalink
Fix draft tags
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Aug 29, 2023
1 parent d3523b7 commit d12575c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Planet/Entities/DraftModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,16 @@ class DraftModel: Identifiable, Equatable, Hashable, Codable, ObservableObject {
return title.isEmpty && content.isEmpty && attachments.isEmpty
}

var createdAt: Date {
// Return the creation date of the infoPath
if let attributes = try? FileManager.default.attributesOfItem(atPath: infoPath.path),
let creationDate = attributes[.creationDate] as? Date
{
return creationDate
}
return date
}

// MARK: -

private func processAttachment(
Expand Down
8 changes: 8 additions & 0 deletions Planet/Writer/WriterStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ import Foundation
draft = try DraftModel.create(from: article)
article.draft = draft
}
// If draft is created earlier than August 29, 2023, fix tags
let tagsFeatureDate = Date(timeIntervalSince1970: 1693292400)
if draft.createdAt < tagsFeatureDate {
if let articleTags = article.tags {
draft.tags = articleTags
try? draft.save()
}
}
draft.initialContentSHA256 = draft.contentSHA256()
openWriterWindow(forDraft: draft)
}
Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 1587
CURRENT_PROJECT_VERSION = 1593

0 comments on commit d12575c

Please sign in to comment.