createDocument now queues and syncs like the other offline-capable writes, closing the gap deliberately left open earlier this session. Synthesizes a pending-<uuid> document (same placeholder scheme as pin/star/subscribe), caches it so it's immediately readable/openable, and queues the real create. On sync, the server's real document replaces the placeholder in the cache — no dead orphan entries. Editing that same still-unsynced document folds the edit into the pending create's payload instead of queuing a separate update, which would otherwise target the placeholder id and 404 forever once flushed. CreateDocumentRequest widened Encodable -> Codable for the queue round-trip. Known limitation: a reader still open on that exact document at the moment it syncs in the background keeps holding the stale placeholder id until navigated away and back. Narrow, not solved generally here. 3 new OutlineKit tests (57/57). Removed the now-unneeded offline restriction on the reader's New Document button/menu item.
24 lines
591 B
Swift
24 lines
591 B
Swift
import Foundation
|
|
|
|
public struct CreateDocumentRequest: Codable, Sendable {
|
|
public let title: String
|
|
public let text: String
|
|
public let collectionId: String
|
|
public let parentDocumentId: String?
|
|
public let publish: Bool
|
|
|
|
public init(
|
|
title: String,
|
|
text: String,
|
|
collectionId: String,
|
|
parentDocumentId: String? = nil,
|
|
publish: Bool = true
|
|
) {
|
|
self.title = title
|
|
self.text = text
|
|
self.collectionId = collectionId
|
|
self.parentDocumentId = parentDocumentId
|
|
self.publish = publish
|
|
}
|
|
}
|