-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
342cb34
commit 3b626bb
Showing
14 changed files
with
168 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { AppConfig } from "./app-config"; | ||
|
||
export interface AppConfigRepository { | ||
getAppConfig(): AppConfig; | ||
setAppConfig(newAppConfig: AppConfig): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface AppConfig { | ||
userSettingsFilePath: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AppConfig } from "./app-config"; | ||
import { join } from "path"; | ||
import { homedir } from "os"; | ||
|
||
export const defaultAppConfig: AppConfig = { | ||
userSettingsFilePath: join(homedir(), "ueli.config.json"), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AppConfigRepository } from "./app-config-repository"; | ||
import Store = require("electron-store"); | ||
import { AppConfig } from "./app-config"; | ||
import { join } from "path"; | ||
import { homedir } from "os"; | ||
|
||
export class ElectronStoreAppConfigRepository implements AppConfigRepository { | ||
private store: Store; | ||
private configKey = "app-config"; | ||
private defaultAppConfig: AppConfig = { | ||
userSettingsFilePath: join(homedir(), "ueli.config.json"), | ||
}; | ||
|
||
constructor() { | ||
this.store = new Store(); | ||
} | ||
|
||
public getAppConfig(): AppConfig { | ||
const appConfig = this.store.get(this.configKey); | ||
return appConfig !== undefined | ||
? appConfig | ||
: this.defaultAppConfig; | ||
} | ||
|
||
public setAppConfig(newAppConfig: AppConfig): void { | ||
this.store.set(this.configKey, newAppConfig); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.