mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 15:39:11 +00:00
Fix to lastLoadedProject being null (#830)
This commit is contained in:
@@ -83,14 +83,21 @@ export const resolveExternalsDirectory = join(isProduction ? getAppDataPath() :
|
|||||||
export const appStatePath = join(getAppDataPath(), config.appState);
|
export const appStatePath = join(getAppDataPath(), config.appState);
|
||||||
export const uploadsFolderPath = join(getAppDataPath(), config.uploads);
|
export const uploadsFolderPath = join(getAppDataPath(), config.uploads);
|
||||||
|
|
||||||
|
const ensureAppState = () => {
|
||||||
|
ensureDirectory(getAppDataPath());
|
||||||
|
fs.writeFileSync(appStatePath, JSON.stringify({ lastLoadedProject: 'db.json' }));
|
||||||
|
};
|
||||||
|
|
||||||
const getLastLoadedProject = () => {
|
const getLastLoadedProject = () => {
|
||||||
try {
|
try {
|
||||||
const appState = JSON.parse(fs.readFileSync(appStatePath, 'utf8'));
|
const appState = JSON.parse(fs.readFileSync(appStatePath, 'utf8'));
|
||||||
|
if (!appState.lastLoadedProject) {
|
||||||
|
ensureAppState();
|
||||||
|
}
|
||||||
return appState.lastLoadedProject;
|
return appState.lastLoadedProject;
|
||||||
} catch {
|
} catch {
|
||||||
if (!isTest) {
|
if (!isTest) {
|
||||||
ensureDirectory(getAppDataPath());
|
ensureAppState();
|
||||||
fs.writeFileSync(appStatePath, JSON.stringify({ lastLoadedProject: 'db.json' }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user