Fixes theme change for the preview route

parent 37c2ad12
Pipeline #17949 passed with stages
in 8 minutes and 53 seconds
......@@ -79,7 +79,7 @@ export class HomeComponent implements OnInit, OnDestroy {
return this._ownQuizzes;
}
private readonly _routerSubscription: Subscription;
private _routerSubscription: Subscription;
constructor(
@Inject(PLATFORM_ID) private platformId: Object,
......@@ -106,17 +106,6 @@ export class HomeComponent implements OnInit, OnDestroy {
this.footerBarService.TYPE_REFERENCE = HomeComponent.TYPE;
this._routerSubscription = this.route.params.subscribe(params => {
if (!Object.keys(params).length) {
return;
}
if (isPlatformBrowser(this.platformId)) {
this.storageService.create(DB_TABLE.CONFIG, STORAGE_KEY.DEFAULT_THEME, params.themeId).subscribe();
}
this.themesService.updateCurrentlyUsedTheme();
this.i18nService.setLanguage(<LANGUAGE>params.languageId.toUpperCase());
});
footerBarService.replaceFooterElements([
this.footerBarService.footerElemAbout,
this.footerBarService.footerElemTranslation,
......@@ -164,7 +153,19 @@ export class HomeComponent implements OnInit, OnDestroy {
}
public ngOnInit(): void {
this.themesService.updateCurrentlyUsedTheme();
this._routerSubscription = this.route.params.subscribe(async params => {
if (!Object.keys(params).length || !params.themeId || !params.languageId) {
this.themesService.updateCurrentlyUsedTheme();
return;
}
if (isPlatformBrowser(this.platformId)) {
await this.storageService.delete(DB_TABLE.CONFIG, STORAGE_KEY.DEFAULT_THEME).toPromise();
await this.storageService.create(DB_TABLE.CONFIG, STORAGE_KEY.DEFAULT_THEME, params.themeId).toPromise();
this.themesService.updateCurrentlyUsedTheme();
}
this.i18nService.setLanguage(<LANGUAGE>params.languageId.toUpperCase());
});
}
public ngOnDestroy(): void {
......
......@@ -66,7 +66,9 @@ export class ThemesService {
new Promise(resolve => {
if (this.currentQuizService.quiz && this.currentQuizService.quiz.sessionConfig.theme) {
resolve(this.currentQuizService.quiz.sessionConfig.theme);
return;
}
resolve();
}),
]);
const usedTheme = themeConfig[0] || themeConfig[1] || themeConfig[2];
......
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