Skip to content
Snippets Groups Projects
Commit 8cb918f6 authored by jojohoch's avatar jojohoch
Browse files

[player] Add method for checking unit definition version to UnitComp.

parent dd8ba4d4
No related branches found
No related tags found
No related merge requests found
Pipeline #49452 passed
......@@ -54,16 +54,10 @@ export class UnitComponent implements OnInit {
try {
LogService.debug('player: unitDefinition', message.unitDefinition);
const unitDefinition = JSON.parse(message.unitDefinition as string);
if (!VersionManager.hasCompatibleVersion(unitDefinition)) {
if (VersionManager.isNewer(unitDefinition)) {
throw Error(this.translateService.instant('errorMessage.unitDefinitionIsNewer'));
}
throw Error(this.translateService.instant('errorMessage.unitDefinitionIsOutdated'));
}
this.checkUnitdefinitionVersion(unitDefinition);
const unit: Unit = new Unit(unitDefinition);
this.pages = unit.pages;
this.playerConfig = message.playerConfig || {};
LogService.info('player: unitStateElementCodes', this.unitStateService.elementCodes);
this.metaDataService.resourceURL = this.playerConfig.directDownloadUrl;
this.veronaPostService.sessionID = message.sessionId;
this.initElementCodes(message, unit);
......@@ -89,6 +83,15 @@ export class UnitComponent implements OnInit {
}
}
private checkUnitdefinitionVersion(unitDefinition: Record<string, unknown>): void {
if (!VersionManager.hasCompatibleVersion(unitDefinition)) {
if (VersionManager.isNewer(unitDefinition)) {
throw Error(this.translateService.instant('errorMessage.unitDefinitionIsNewer'));
}
throw Error(this.translateService.instant('errorMessage.unitDefinitionIsOutdated'));
}
}
private showErrorDialog(text: string): void {
this.dialog.open(UnitDefErrorDialogComponent, {
data: { text: text },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment