From f480f8cc827d318285e298e24abf577350c38a92 Mon Sep 17 00:00:00 2001 From: James Chien Date: Mon, 6 Jul 2020 15:18:35 +0800 Subject: [PATCH] Fix uninitialized recordPreset userdata Signed-off-by: James Chien --- src/app/app.component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 67b7355e..2d09dd31 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,6 +6,7 @@ import { filter, first, switchMap, take } from 'rxjs/operators'; import { Plugins, StatusBarStyle } from '@capacitor/core'; import { LanguageService } from '@core/services/language.service'; +import { RecordPreset } from '@core/services/preset.service'; import { Platform } from '@ionic/angular'; import { DataStoreService } from './core/services/store/data-store.service'; @@ -30,6 +31,9 @@ export class AppComponent { .pipe( switchMap(() => this.language.init()), switchMap(() => this.dataStore.userData$.pipe(take(1))), + switchMap(userData => { + return (userData.recordPreset) ? of(userData) : this.dataStore.updateUserData({ recordPreset: RecordPreset.COMMON_COLD }); + }) ) .subscribe(userData => { if (userData.newUser) {