updates plug with all sorts of awesome improvements
This commit is contained in:
@@ -20,7 +20,7 @@ public final class PageStore {
|
||||
.appendingPathComponent("page.md")
|
||||
}
|
||||
|
||||
/// The page file as read at launch; an empty page when there was no file.
|
||||
/// The page file as read at launch; the first page when there was no file.
|
||||
public let loaded: PageFile
|
||||
|
||||
/// Makes the page file text when a save runs, so a keystroke costs no conversion; nil writes nothing.
|
||||
@@ -35,12 +35,13 @@ public final class PageStore {
|
||||
@ObservationIgnored private var pending: Task<Void, Never>?
|
||||
@ObservationIgnored private var isDirty = false
|
||||
|
||||
/// Reads the page file; a missing file gives an empty page.
|
||||
/// Reads the page file; a missing file gives `firstPage`, which the next flush writes unless it is empty.
|
||||
/// - Throws: `PageStoreError.unreadable` when the file exists but cannot be read.
|
||||
public init(
|
||||
url: URL = PageStore.defaultURL,
|
||||
debounce: Duration = .milliseconds(500),
|
||||
write: @escaping @Sendable (Data, URL) throws -> Void = PageStore.writeAtomically
|
||||
write: @escaping @Sendable (Data, URL) throws -> Void = PageStore.writeAtomically,
|
||||
firstPage: @autoclosure () -> PageFile = WelcomeText.page(createdAt: Date())
|
||||
) throws {
|
||||
self.url = url
|
||||
self.debounce = debounce
|
||||
@@ -51,7 +52,8 @@ public final class PageStore {
|
||||
}
|
||||
loaded = PageFile(text: text)
|
||||
} else {
|
||||
loaded = PageFile()
|
||||
loaded = firstPage()
|
||||
isDirty = !loaded.lines.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user