mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
refactor: project service boundaries
This commit is contained in:
committed by
Carlos Valente
parent
20d9df2501
commit
ad69c0ff80
@@ -8,10 +8,10 @@ interface Config {
|
||||
}
|
||||
|
||||
/**
|
||||
* Service manages Ontime's runtime memory between boots
|
||||
* Manages Ontime's runtime memory between boots
|
||||
*/
|
||||
|
||||
class AppStateService {
|
||||
class AppState {
|
||||
private config: Low<Config>;
|
||||
private pathToFile: string;
|
||||
private didInit = false;
|
||||
@@ -28,7 +28,7 @@ class AppStateService {
|
||||
this.didInit = true;
|
||||
}
|
||||
|
||||
async get(): Promise<Config> {
|
||||
private async get(): Promise<Config> {
|
||||
if (!this.didInit) {
|
||||
await this.init();
|
||||
}
|
||||
@@ -36,6 +36,11 @@ class AppStateService {
|
||||
return this.config.data;
|
||||
}
|
||||
|
||||
async getLastLoadedProject(): Promise<string> {
|
||||
const data = await this.get();
|
||||
return data.lastLoadedProject;
|
||||
}
|
||||
|
||||
async updateDatabaseConfig(filename: string): Promise<void> {
|
||||
if (isTest) return;
|
||||
|
||||
@@ -48,4 +53,4 @@ class AppStateService {
|
||||
}
|
||||
}
|
||||
|
||||
export const appStateService = new AppStateService(appStatePath);
|
||||
export const appStateProvider = new AppState(appStatePath);
|
||||
|
||||
Reference in New Issue
Block a user