mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 17:03:53 +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 uploadsFolderPath = join(getAppDataPath(), config.uploads);
|
||||
|
||||
const ensureAppState = () => {
|
||||
ensureDirectory(getAppDataPath());
|
||||
fs.writeFileSync(appStatePath, JSON.stringify({ lastLoadedProject: 'db.json' }));
|
||||
};
|
||||
|
||||
const getLastLoadedProject = () => {
|
||||
try {
|
||||
const appState = JSON.parse(fs.readFileSync(appStatePath, 'utf8'));
|
||||
if (!appState.lastLoadedProject) {
|
||||
ensureAppState();
|
||||
}
|
||||
return appState.lastLoadedProject;
|
||||
} catch {
|
||||
if (!isTest) {
|
||||
ensureDirectory(getAppDataPath());
|
||||
fs.writeFileSync(appStatePath, JSON.stringify({ lastLoadedProject: 'db.json' }));
|
||||
ensureAppState();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user