Skip to content

Commit

Permalink
Fix the concurrency issue when saving and publishing in Draft.saveToA…
Browse files Browse the repository at this point in the history
…rticle()
  • Loading branch information
livid committed Sep 11, 2024
1 parent e69f744 commit 0a0b0c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions Planet/Entities/DraftModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,17 @@ class DraftModel: Identifiable, Equatable, Hashable, Codable, ObservableObject {
planet.updated = Date()
try planet.save()

Task {
Task(priority: .userInitiated) {
try await planet.savePublic()
try await planet.publish()
Task(priority: .background) {
await article.prewarm()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
Task(priority: .userInitiated) {
try await planet.publish()
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
Task(priority: .background) {
await article.prewarm()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Planet/Labs/Quick Post/QuickPostView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ struct QuickPostView: View {
planet.updated = Date()
try planet.save()

Task {
Task(priority: .userInitiated) {
try await planet.savePublic()
try await planet.publish()
Task(priority: .background) {
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 = 2238
CURRENT_PROJECT_VERSION = 2239

0 comments on commit 0a0b0c7

Please sign in to comment.