diff --git a/src/app/domains/pos/components/splash.component.ts b/src/app/domains/pos/components/splash.component.ts index 3481b37..4b6ee31 100644 --- a/src/app/domains/pos/components/splash.component.ts +++ b/src/app/domains/pos/components/splash.component.ts @@ -1,5 +1,6 @@ +import { brandingConfig } from '@/branding/branding.config'; import { PwaInstallService } from '@/core/services'; -import { Component, EventEmitter, inject, Output } from '@angular/core'; +import { Component, effect, EventEmitter, inject, Output } from '@angular/core'; import { ButtonDirective } from 'primeng/button'; import { finalize, forkJoin } from 'rxjs'; import images from 'src/assets/images'; @@ -20,42 +21,46 @@ export class PosSplashComponent { private readonly pwaInstallService = inject(PwaInstallService); logo = images.logo; - requireInstall = false; - // requireInstall = brandingConfig.enableInstallPrompt; + // requireInstall = false; + requireInstall = brandingConfig.enableInstallPrompt; pwaInstalled = this.pwaInstallService.isInstalled; canInstall = this.pwaInstallService.canInstall; private installPromptShown = false; - // constructor() { - // effect(() => { - // if (!this.requireInstall || this.pwaInstalled() || this.installPromptShown) { - // return; - // } + constructor() { + effect(() => { + if (!this.requireInstall || this.pwaInstalled() || this.installPromptShown) { + this.getData(); + return; + } - // if (this.canInstall()) { - // this.installPromptShown = true; - // this.pwaInstallService.openInstallConfirm(); - // } - // }); - // } + if (this.canInstall()) { + this.installPromptShown = true; + this.pwaInstallService.openInstallConfirm(); + } + }); + } async ngOnInit() { const data = await this.deviceInfoStore.getData(); + + if (!this.requireInstall || this.pwaInstalled()) { + this.getData(); + } + + if (this.canInstall()) { + this.pwaInstallService.openInstallConfirm(); + this.installPromptShown = true; + } + } + + async getData() { const profileObs = await this.posProfileStore.getData(); const infoObs = await this.posInfoStore.getData(); - forkJoin([profileObs, infoObs]) .pipe( finalize(() => { - if (!this.requireInstall || this.pwaInstalled()) { - this.onComplete.emit(); - return; - } - - if (this.canInstall()) { - this.pwaInstallService.openInstallConfirm(); - this.installPromptShown = true; - } + this.onComplete.emit(); }), ) .subscribe(([profileResult, infoResult]) => {});