mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 23:19:09 +00:00
refactor: move welcome modal logic to AppStateService
The logic for deciding whether to show the welcome modal has been moved from `app.ts` to `AppStateService.ts`. The `getShowWelcomeDialog` function now accepts a boolean indicating whether a restore point exists and returns `false` if it does. This keeps the business logic out of the main application file and in the relevant service.
This commit is contained in:
committed by
Carlos Valente
parent
14f9472250
commit
7b5f797c95
@@ -184,10 +184,7 @@ export const startServer = async (): Promise<{ message: string; serverPort: numb
|
|||||||
// the express server must be started before the socket otherwise the on error event listener will not attach properly
|
// the express server must be started before the socket otherwise the on error event listener will not attach properly
|
||||||
const resultPort = await serverTryDesiredPort(expressServer, desiredPort);
|
const resultPort = await serverTryDesiredPort(expressServer, desiredPort);
|
||||||
await getDataProvider().setSettings({ ...settings, serverPort: resultPort });
|
await getDataProvider().setSettings({ ...settings, serverPort: resultPort });
|
||||||
let showWelcome = await getShowWelcomeDialog();
|
const showWelcome = await getShowWelcomeDialog(!!restorePoint);
|
||||||
if (restorePoint) {
|
|
||||||
showWelcome = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.init(expressServer, showWelcome, prefix);
|
socket.init(expressServer, showWelcome, prefix);
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ export async function setLastLoadedRundown(rundownKey: string): Promise<void> {
|
|||||||
await config.write();
|
await config.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getShowWelcomeDialog(): Promise<boolean> {
|
export async function getShowWelcomeDialog(restorePointExists: boolean): Promise<boolean> {
|
||||||
// in test environment, we do not want the dialog
|
// in test environment, we do not want the dialog
|
||||||
if (isTest) return false;
|
if (isTest) return false;
|
||||||
|
|
||||||
|
if (restorePointExists) return false;
|
||||||
|
|
||||||
await config.read();
|
await config.read();
|
||||||
return config.data.showWelcomeDialog ?? true; // default to true
|
return config.data.showWelcomeDialog ?? true; // default to true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user