mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 04:13:47 +00:00
Remove serverport from project file (#1957)
* feat: get server port from app satate or env optional startup port from env will always override function for parsing port from env populate default port in app state add test for migration * bump version
This commit is contained in:
committed by
GitHub
parent
1fe58e21be
commit
c1fcdf7065
@@ -10,6 +10,7 @@ interface AppState {
|
||||
projectName?: string;
|
||||
rundownId?: string;
|
||||
showWelcomeDialog?: boolean;
|
||||
serverPort?: number;
|
||||
}
|
||||
|
||||
const adapter = new JSONFile<AppState>(publicFiles.appState);
|
||||
@@ -61,3 +62,13 @@ export async function setShowWelcomeDialog(show: boolean): Promise<boolean> {
|
||||
await config.write();
|
||||
return show;
|
||||
}
|
||||
|
||||
export async function getServerPort(): Promise<number | undefined> {
|
||||
await config.read();
|
||||
return config.data.serverPort;
|
||||
}
|
||||
|
||||
export async function setServerPort(port: number): Promise<void> {
|
||||
config.data.serverPort = port;
|
||||
await config.write();
|
||||
}
|
||||
|
||||
@@ -183,7 +183,10 @@ export async function initialiseProject(): Promise<string> {
|
||||
}
|
||||
|
||||
try {
|
||||
const projectName = await loadProjectFile(lastLoaded.projectName, lastLoaded.rundownId);
|
||||
const projectName = await loadProjectFile(lastLoaded.projectName, {
|
||||
rundownId: lastLoaded.rundownId,
|
||||
initialLoad: true,
|
||||
});
|
||||
return projectName;
|
||||
} catch (error) {
|
||||
// if we are here, most likely the json parsing failed and the file is corrupt
|
||||
@@ -207,7 +210,10 @@ export async function initialiseProject(): Promise<string> {
|
||||
* @throws
|
||||
* @param fileName file name of the project including the extension
|
||||
*/
|
||||
export async function loadProjectFile(fileName: string, rundownId?: string): Promise<string> {
|
||||
export async function loadProjectFile(
|
||||
fileName: string,
|
||||
options?: { rundownId?: string; initialLoad?: boolean },
|
||||
): Promise<string> {
|
||||
const filePath = doesProjectExist(fileName);
|
||||
if (filePath === null) {
|
||||
throw new Error('Project file not found');
|
||||
@@ -215,7 +221,7 @@ export async function loadProjectFile(fileName: string, rundownId?: string): Pro
|
||||
|
||||
// when loading a project file, we allow parsing to fail and interrupt the process
|
||||
const fileData = await parseJsonFile(filePath);
|
||||
const result = parseDatabaseModel(fileData);
|
||||
const result = parseDatabaseModel(fileData, options?.initialLoad);
|
||||
let parsedFileName = fileName;
|
||||
|
||||
if (result.migrated) {
|
||||
@@ -226,7 +232,7 @@ export async function loadProjectFile(fileName: string, rundownId?: string): Pro
|
||||
parsedFileName = await handleCorruptedFile(filePath, parsedFileName);
|
||||
}
|
||||
|
||||
const projectName = await loadProject(result.data, parsedFileName, rundownId);
|
||||
const projectName = await loadProject(result.data, parsedFileName, options?.rundownId);
|
||||
return projectName;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user