improvements on the ui

This commit is contained in:
2026-11-25 07:14:49 +01:00
parent 3afdb6d67f
commit b7c72b9e16
249 changed files with 19702 additions and 17358 deletions
+8 -1
View File
@@ -15,7 +15,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
NSApp.mainMenu = MainMenu.make()
let store: PageStore
do {
store = try PageStore()
store = try PageStore(pruneAt: Date())
} catch {
// No store means nothing can flush over the unreadable page file on quit.
showUnreadable(error)
@@ -23,6 +23,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return
}
self.store = store
removeUnusedImages(of: store)
let controller = PageWindowController(store: store)
windowController = controller
controller.onHide = { [weak self] in self?.hidePlak() }
@@ -108,6 +109,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}
/// Runs only when the page file holds the page: with no page file, or a failed write, it would delete used images.
private func removeUnusedImages(of store: PageStore) {
guard store.saveError == nil, FileManager.default.fileExists(atPath: store.url.path) else { return }
ImageStore(base: store.url.deletingLastPathComponent()).removeUnused(keeping: store.loaded.imagePaths)
}
private func showUnreadable(_ error: Error) {
let alert = NSAlert()
alert.alertStyle = .critical