1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-07 03:20:09 +02:00

Load custom preferences file

This commit is contained in:
2022-01-03 16:49:50 +01:00
parent 722e082526
commit 3bca3117f9
3 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
//
// CustomPrefs.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 03/01/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Foundation
struct CustomPrefs: Decodable {
let scanApps: [String]
private enum CodingKeys: String, CodingKey {
case scanApps = "scan_apps"
}
}

View File

@@ -24,11 +24,21 @@ class Preferences {
static var shared = Preferences()
var customPreferences: CustomPrefs
var cachedPreferences: [PreferenceName: Any?]
public init() {
Preferences.handleFirstTimeLaunch()
cachedPreferences = Self.cache()
do {
customPreferences = try JSONDecoder().decode(
CustomPrefs.self,
from: try! String(contentsOf: URL(fileURLWithPath: "/Users/\(Paths.whoami)/.phpmon.conf.json"), encoding: .utf8).data(using: .utf8)!
)
} catch {
customPreferences = CustomPrefs(scanApps: [])
}
}
// MARK: - First Time Run