Rename the InstalledStyleSheets file to InstalledThemes

This commit is contained in:
Maurice Parker 2021-09-23 10:00:53 -05:00
parent f73426f397
commit 71b0a8d476

View File

@ -62,10 +62,10 @@ final class ArticleThemesManager: NSObject, NSFilePresenter {
} }
let themeFilenames = Bundle.main.paths(forResourcesOfType: ArticleTheme.nnwThemeSuffix, inDirectory: nil) let themeFilenames = Bundle.main.paths(forResourcesOfType: ArticleTheme.nnwThemeSuffix, inDirectory: nil)
let installedStyleSheets = readInstalledStyleSheets() ?? [String: Date]() let installedThemes = readInstalledThemes() ?? [String: Date]()
for themeFilename in themeFilenames { for themeFilename in themeFilenames {
let themeName = ArticleTheme.themeNameForPath(themeFilename) let themeName = ArticleTheme.themeNameForPath(themeFilename)
if !installedStyleSheets.keys.contains(themeName) { if !installedThemes.keys.contains(themeName) {
try? importTheme(filename: themeFilename) try? importTheme(filename: themeFilename)
} }
} }
@ -100,9 +100,9 @@ final class ArticleThemesManager: NSObject, NSFilePresenter {
try FileManager.default.copyItem(atPath: filename, toPath: toFilename) try FileManager.default.copyItem(atPath: filename, toPath: toFilename)
let themeName = ArticleTheme.themeNameForPath(filename) let themeName = ArticleTheme.themeNameForPath(filename)
var installedStyleSheets = readInstalledStyleSheets() ?? [String: Date]() var installedThemes = readInstalledThemes() ?? [String: Date]()
installedStyleSheets[themeName] = Date() installedThemes[themeName] = Date()
writeInstalledStyleSheets(installedStyleSheets) writeInstalledThemes(installedThemes)
} }
func deleteTheme(themeName: String) { func deleteTheme(themeName: String) {
@ -178,13 +178,13 @@ private extension ArticleThemesManager {
return nil return nil
} }
func readInstalledStyleSheets() -> [String: Date]? { func readInstalledThemes() -> [String: Date]? {
let filePath = (folderPath as NSString).appendingPathComponent("InstalledStyleSheets.plist") let filePath = (folderPath as NSString).appendingPathComponent("InstalledThemes.plist")
return NSDictionary(contentsOfFile: filePath) as? [String: Date] return NSDictionary(contentsOfFile: filePath) as? [String: Date]
} }
func writeInstalledStyleSheets(_ dict: [String: Date]) { func writeInstalledThemes(_ dict: [String: Date]) {
let filePath = (folderPath as NSString).appendingPathComponent("InstalledStyleSheets.plist") let filePath = (folderPath as NSString).appendingPathComponent("InstalledThemes.plist")
(dict as NSDictionary).write(toFile: filePath, atomically: true) (dict as NSDictionary).write(toFile: filePath, atomically: true)
} }