refactor: project service boundaries

This commit is contained in:
Carlos Valente
2024-06-24 14:09:25 +02:00
committed by Carlos Valente
parent 20d9df2501
commit ad69c0ff80
9 changed files with 168 additions and 144 deletions
@@ -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);