Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main fix state loading #700

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ export class PhoenixMenuNode {

this.childrenActive = jsonObject['childrenActive'];
this.toggleState = jsonObject['toggleState'];
// eslint-disable-next-line
this.toggleState !== undefined && this.onToggle?.(this.toggleState);

this.onToggle?.(this.toggleState);

for (const configState of jsonObject['configs']) {
const nodeConfigs = this.configs.filter(
Expand Down
26 changes: 21 additions & 5 deletions packages/phoenix-event-display/src/managers/url-options-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,32 @@ export class URLOptionsManager {
}

if (!this.urlOptions.get('file') || !this.urlOptions.get('type')) {
console.log('Setting and config from defaults');
file = defaultEventPath;
type = defaultEventType;
} else {
console.log('Setting and config from urlOptions');
file = this.urlOptions.get('file') ?? '';
type = this.urlOptions.get('type')?.toLowerCase() ?? '';
console.log(
'Default file(',
defaultEventPath,
') was overridden by URL options to: ',
file,
);
}

console.log('Loading ', file, 'of type', type);
// Load config from URL
console.log('Try to load event file: ', file, 'of type', type);
// Try to load config from URL
const loadConfig = () => {
if (this.urlOptions.get('config')) {
this.eventDisplay.getLoadingManager().addLoadableItem('url_config');
fetch(this.urlOptions.get('config') ?? '')
.then((res) => res.json())
.then((jsonState) => {
console.log(
'Applying configuration ',
this.urlOptions.get('config'),
' from urlOptions',
);
const stateManager = new StateManager();
stateManager.loadStateFromJSON(jsonState);
})
Expand Down Expand Up @@ -141,7 +150,14 @@ export class URLOptionsManager {
* @returns An empty promise. ;(
*/
private async handleJiveXMLEvent(fileURL: string) {
const fileData = await (await fetch(fileURL)).text();
const fileData = await (
await fetch(fileURL).then((response) => {
if (response.status >= 400 && response.status < 600) {
throw new Error('Bad response from server');
}
return response;
})
).text();
if (!this.configuration.eventDataLoader) {
this.configuration.eventDataLoader = new JiveXMLLoader();
}
Expand Down
Loading