Skip to content

Commit

Permalink
added error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoemp committed Feb 12, 2020
1 parent eabc595 commit 2682569
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/app/core/gui/transcription/transcription.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class TranscriptionComponent implements OnInit,
if (!this.audiomanager.playOnHover && !this.modalOverview.visible) {
let caretpos = -1;

if (!(((this.currentEditor.instance as any).editor) === null || ((this.currentEditor.instance as any).editor) === undefined)) {
if (!isNullOrUndefined(this.currentEditor) && !isNullOrUndefined((this.currentEditor.instance as any).editor)) {
caretpos = (this.currentEditor.instance as any).editor.caretpos;
}

Expand Down Expand Up @@ -187,7 +187,9 @@ export class TranscriptionComponent implements OnInit,
this.alertService.showAlert('success', this.langService.translate('tools.alerts.done', {
value: toolName
}));
(this._currentEditor.instance as any).update();
if (!isNullOrUndefined(this.currentEditor) && !isNullOrUndefined((this.currentEditor.instance as any).editor)) {
(this._currentEditor.instance as any).update();
}
break;
}
},
Expand All @@ -197,13 +199,19 @@ export class TranscriptionComponent implements OnInit,
}));

this.subscrmanager.add(this.modService.showmodal.subscribe((event: { type: string, data, emitter: any }) => {
const editor = this._currentEditor.instance as OCTRAEditor;
editor.disableAllShortcuts();

if (!isNullOrUndefined(this.currentEditor) && !isNullOrUndefined((this.currentEditor.instance as any).editor)) {
const editor = this._currentEditor.instance as OCTRAEditor;
editor.disableAllShortcuts();
}
}));

this.subscrmanager.add(this.modService.closemodal.subscribe((event: { type: string }) => {
const editor = this._currentEditor.instance as OCTRAEditor;
editor.enableAllShortcuts();
if (!isNullOrUndefined(this.currentEditor) && !isNullOrUndefined((this.currentEditor.instance as any).editor)) {
const editor = this._currentEditor.instance as OCTRAEditor;
editor.enableAllShortcuts();
}

}));
}

Expand Down Expand Up @@ -559,7 +567,7 @@ export class TranscriptionComponent implements OnInit,
this._currentEditor = viewContainerRef.createComponent(componentFactory);
let caretpos = -1;

if (!((this.currentEditor.instance as any).editor === null || (this.currentEditor.instance as any).editor === undefined)) {
if (!isNullOrUndefined(this.currentEditor) && !isNullOrUndefined((this.currentEditor.instance as any).editor)) {
caretpos = (this.currentEditor.instance as any).editor.caretpos;
}

Expand Down

0 comments on commit 2682569

Please sign in to comment.