Commit 158baca7 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

fixed error handling for non-existing mostRecentSetup

parent 32e97c8f
{ {
"name": "mc_frontend", "name": "mc_frontend",
"version": "1.0.0", "version": "1.0.2",
"author": "Ionic Framework", "author": "Ionic Framework",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"scripts": { "scripts": {
......
...@@ -23,6 +23,8 @@ import {QueryMC} from 'src/app/models/queryMC'; ...@@ -23,6 +23,8 @@ import {QueryMC} from 'src/app/models/queryMC';
import {Exercise} from 'src/app/models/exercise'; import {Exercise} from 'src/app/models/exercise';
import {Feedback} from 'src/app/models/feedback'; import {Feedback} from 'src/app/models/feedback';
import {PhenomenonMap} from 'src/app/models/phenomenonMap'; import {PhenomenonMap} from 'src/app/models/phenomenonMap';
import {error} from 'selenium-webdriver';
import {reject} from 'q';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -63,6 +65,7 @@ export class CorpusService { ...@@ -63,6 +65,7 @@ export class CorpusService {
if (HelperService.mostRecentSetup) { if (HelperService.mostRecentSetup) {
this.restoreLastCorpus().then(); this.restoreLastCorpus().then();
} }
}, () => {
}); });
}); });
this.initPhenomenonMap(); this.initPhenomenonMap();
...@@ -96,14 +99,16 @@ export class CorpusService { ...@@ -96,14 +99,16 @@ export class CorpusService {
} }
checkAnnisResponse() { checkAnnisResponse() {
return new Promise((resolve) => { return new Promise((outerResolve, outerReject) => {
if (this.annisResponse) { if (this.annisResponse) {
return resolve(); return outerResolve();
} }
this.helperService.loadMostRecentSetup().then(() => { this.helperService.loadMostRecentSetup().then(() => {
this.annisResponse = HelperService.mostRecentSetup.annisResponse; this.annisResponse = HelperService.mostRecentSetup.annisResponse;
this.currentUrn = HelperService.mostRecentSetup.currentUrn; this.currentUrn = HelperService.mostRecentSetup.currentUrn;
return resolve(); return outerResolve();
}, () => {
return outerReject();
}); });
}); });
} }
......
...@@ -237,10 +237,15 @@ export class HelperService { ...@@ -237,10 +237,15 @@ export class HelperService {
} }
loadMostRecentSetup() { loadMostRecentSetup() {
return new Promise(async (resolve) => { return new Promise(async (resolve, reject) => {
this.storage.get(HelperService.config['localStorageKeyMostRecentSetup']).then((mrs: string) => { this.storage.get(HelperService.config['localStorageKeyMostRecentSetup']).then((mrs: string) => {
if (!mrs) {
return reject();
}
HelperService.mostRecentSetup = JSON.parse(mrs); HelperService.mostRecentSetup = JSON.parse(mrs);
return resolve(); return resolve();
}, (error: any) => {
return reject();
}); });
}); });
} }
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
<div class="toolbar-right"> <div class="toolbar-right">
<ion-spinner *ngIf="HelperService.isLoading"></ion-spinner> <ion-spinner *ngIf="HelperService.isLoading"></ion-spinner>
<ion-select [(ngModel)]="HelperService.currentLanguage" (ngModelChange)="changeLanguage($event)" <ion-select [(ngModel)]="HelperService.currentLanguage" (ngModelChange)="changeLanguage($event)"
name="currentLanguage" name="currentLanguage" placeholder="{{HelperService.currentLanguage?.name}}">
placeholder="{{HelperService.currentLanguage.name}}">
<ion-select-option *ngFor="let lang of HelperService.languages" <ion-select-option *ngFor="let lang of HelperService.languages"
value="{{lang.shortcut}}">{{lang.name}}</ion-select-option> value="{{lang.shortcut}}">{{lang.name}}</ion-select-option>
</ion-select> </ion-select>
......
...@@ -42,6 +42,7 @@ export class PreviewPage implements OnDestroy { ...@@ -42,6 +42,7 @@ export class PreviewPage implements OnDestroy {
this.corpusService.checkAnnisResponse().then(() => { this.corpusService.checkAnnisResponse().then(() => {
this.processAnnisResponse(this.corpusService.annisResponse); this.processAnnisResponse(this.corpusService.annisResponse);
this.initH5P(); this.initH5P();
}, () => {
}); });
}); });
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment