mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 08:39:34 +00:00
refactor: last project may not exist
This commit is contained in:
committed by
Carlos Valente
parent
d94c1d4252
commit
c944e77bc1
@@ -4,7 +4,7 @@ import { JSONFile } from 'lowdb/node';
|
|||||||
import { appStatePath, isTest } from '../../setup/index.js';
|
import { appStatePath, isTest } from '../../setup/index.js';
|
||||||
|
|
||||||
interface Config {
|
interface Config {
|
||||||
lastLoadedProject: string;
|
lastLoadedProject?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +19,7 @@ class AppState {
|
|||||||
constructor(appStatePath: string) {
|
constructor(appStatePath: string) {
|
||||||
this.pathToFile = appStatePath;
|
this.pathToFile = appStatePath;
|
||||||
const adapter = new JSONFile<Config>(this.pathToFile);
|
const adapter = new JSONFile<Config>(this.pathToFile);
|
||||||
this.config = new Low<Config>(adapter, null);
|
this.config = new Low<Config>(adapter, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
@@ -41,7 +41,7 @@ class AppState {
|
|||||||
return lastLoaded === projectName;
|
return lastLoaded === projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLastLoadedProject(): Promise<string> {
|
async getLastLoadedProject(): Promise<string | undefined> {
|
||||||
const data = await this.get();
|
const data = await this.get();
|
||||||
return data.lastLoadedProject;
|
return data.lastLoadedProject;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export async function getProjectList(): Promise<ProjectFileListResponse> {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
files,
|
files,
|
||||||
lastLoadedProject: removeFileExtension(lastLoadedProject),
|
lastLoadedProject: lastLoadedProject ? removeFileExtension(lastLoadedProject) : '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user