Skip to content

Commit

Permalink
feat: persist settings and load from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBorai committed Dec 22, 2023
1 parent 4706282 commit d538528
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ extension SettingsData {

/// Explicit decoder init for setting default values when key is not present in `JSON`
init(from decoder: Decoder) throws {
print("From decoder")
let container = try decoder.container(keyedBy: CodingKeys.self)

self.ignoreGlobPatterns = try container.decodeIfPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ final class SearchSettingsModel: ObservableObject {
baseURL.appendingPathComponent("settings.json", isDirectory: true)
}

/// The currently existent Search Ignore Glob Patterns.
/// Stores the new values from the Search Settings Model into the settings.json whenever
/// `ignoreGlobPatterns` is updated
@Published var ignoreGlobPatterns: [GlobPattern] {
didSet {
DispatchQueue.main.async {
Expand All @@ -57,7 +58,10 @@ final class SearchSettingsModel: ObservableObject {
}
}

/// Reads settings file for Search Settings and updates the values in this model
/// correspondingly
private init() {
self.ignoreGlobPatterns = []
let value = Settings[\.search].ignoreGlobPatterns
self.ignoreGlobPatterns = value
}
}

0 comments on commit d538528

Please sign in to comment.