Import old content, load from disk

This commit is contained in:
Christoph Hagen
2024-11-18 20:19:20 +01:00
parent 0989f06d87
commit 943d8d962b
24 changed files with 1326 additions and 210 deletions

View File

@ -52,13 +52,19 @@ struct SettingsView: View {
private func selectContentFolder() {
isSelectingContentFolder = true
//showFileImporter = true
savePanelUsingOpenPanel(key: "contentPathBookmark")
guard let url = savePanelUsingOpenPanel(key: "contentPathBookmark") else {
return
}
self.contentPath = url.path()
}
private func selectOutputFolder() {
isSelectingContentFolder = false
//showFileImporter = true
savePanelUsingOpenPanel(key: "outputPathBookmark")
guard let url = savePanelUsingOpenPanel(key: "outputPathBookmark") else {
return
}
self.outputPath = url.path()
}
private func didSelectContentFolder(_ result: Result<URL, any Error>) {
@ -99,7 +105,7 @@ struct SettingsView: View {
content.generateFeed(for: language, bookmarkKey: "outputPathBookmark")
}
func savePanelUsingOpenPanel(key: String) {
func savePanelUsingOpenPanel(key: String) -> URL? {
let panel = NSOpenPanel()
// Sets up so user can only select a single directory
panel.canChooseFiles = false
@ -112,12 +118,13 @@ struct SettingsView: View {
let response = panel.runModal()
guard response == .OK else {
return
return nil
}
guard let url = panel.url else {
return
return nil
}
saveSecurityScopedBookmark(url, key: key)
return url
}
func saveSecurityScopedBookmark(_ url: URL, key: String) {