Reset data after folder change
This commit is contained in:
@ -47,7 +47,6 @@ extension Content {
|
||||
}
|
||||
|
||||
let settings = try storage.loadSettings() // Uses defaults if missing
|
||||
print("Loaded settings")
|
||||
let imageDescriptions = try storage.loadFileDescriptions().reduce(into: [:]) { descriptions, description in
|
||||
descriptions[description.fileId] = description
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ final class Content: ObservableObject {
|
||||
var tagOverview: TagOverviewPage?
|
||||
|
||||
@Published
|
||||
private(set) var results: [ItemId : PageGenerationResults] = [:]
|
||||
private(set) var results: [ItemId : PageGenerationResults]
|
||||
|
||||
@Published
|
||||
private(set) var isGeneratingWebsite = false
|
||||
@ -43,15 +43,27 @@ final class Content: ObservableObject {
|
||||
self.tags = tags
|
||||
self.files = files
|
||||
self.tagOverview = tagOverview
|
||||
self.results = [:]
|
||||
}
|
||||
|
||||
init() {
|
||||
self.settings = .mock
|
||||
self.settings = .default
|
||||
self.posts = []
|
||||
self.pages = []
|
||||
self.tags = []
|
||||
self.files = []
|
||||
self.tagOverview = nil
|
||||
self.results = [:]
|
||||
}
|
||||
|
||||
private func clear() {
|
||||
self.settings = .default
|
||||
self.posts = []
|
||||
self.pages = []
|
||||
self.tags = []
|
||||
self.files = []
|
||||
self.tagOverview = nil
|
||||
self.results = [:]
|
||||
}
|
||||
|
||||
var images: [FileResource] {
|
||||
@ -73,4 +85,16 @@ final class Content: ObservableObject {
|
||||
// TODO: Insert at correct index?
|
||||
pages.insert(page, at: 0)
|
||||
}
|
||||
|
||||
func update(contentPath: URL) {
|
||||
guard storage.save(contentPath: contentPath) else {
|
||||
return
|
||||
}
|
||||
clear()
|
||||
do {
|
||||
try loadFromDisk()
|
||||
} catch {
|
||||
print("Failed to reload content: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user