feat: enhance PWA installation logic and streamline component initialization
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
|
import { brandingConfig } from '@/branding/branding.config';
|
||||||
import { PwaInstallService } from '@/core/services';
|
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 { ButtonDirective } from 'primeng/button';
|
||||||
import { finalize, forkJoin } from 'rxjs';
|
import { finalize, forkJoin } from 'rxjs';
|
||||||
import images from 'src/assets/images';
|
import images from 'src/assets/images';
|
||||||
@@ -20,42 +21,46 @@ export class PosSplashComponent {
|
|||||||
private readonly pwaInstallService = inject(PwaInstallService);
|
private readonly pwaInstallService = inject(PwaInstallService);
|
||||||
|
|
||||||
logo = images.logo;
|
logo = images.logo;
|
||||||
requireInstall = false;
|
// requireInstall = false;
|
||||||
// requireInstall = brandingConfig.enableInstallPrompt;
|
requireInstall = brandingConfig.enableInstallPrompt;
|
||||||
pwaInstalled = this.pwaInstallService.isInstalled;
|
pwaInstalled = this.pwaInstallService.isInstalled;
|
||||||
canInstall = this.pwaInstallService.canInstall;
|
canInstall = this.pwaInstallService.canInstall;
|
||||||
private installPromptShown = false;
|
private installPromptShown = false;
|
||||||
|
|
||||||
// constructor() {
|
constructor() {
|
||||||
// effect(() => {
|
effect(() => {
|
||||||
// if (!this.requireInstall || this.pwaInstalled() || this.installPromptShown) {
|
if (!this.requireInstall || this.pwaInstalled() || this.installPromptShown) {
|
||||||
// return;
|
this.getData();
|
||||||
// }
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if (this.canInstall()) {
|
if (this.canInstall()) {
|
||||||
// this.installPromptShown = true;
|
this.installPromptShown = true;
|
||||||
// this.pwaInstallService.openInstallConfirm();
|
this.pwaInstallService.openInstallConfirm();
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const data = await this.deviceInfoStore.getData();
|
const data = await this.deviceInfoStore.getData();
|
||||||
const profileObs = await this.posProfileStore.getData();
|
|
||||||
const infoObs = await this.posInfoStore.getData();
|
|
||||||
|
|
||||||
forkJoin([profileObs, infoObs])
|
|
||||||
.pipe(
|
|
||||||
finalize(() => {
|
|
||||||
if (!this.requireInstall || this.pwaInstalled()) {
|
if (!this.requireInstall || this.pwaInstalled()) {
|
||||||
this.onComplete.emit();
|
this.getData();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.canInstall()) {
|
if (this.canInstall()) {
|
||||||
this.pwaInstallService.openInstallConfirm();
|
this.pwaInstallService.openInstallConfirm();
|
||||||
this.installPromptShown = true;
|
this.installPromptShown = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getData() {
|
||||||
|
const profileObs = await this.posProfileStore.getData();
|
||||||
|
const infoObs = await this.posInfoStore.getData();
|
||||||
|
forkJoin([profileObs, infoObs])
|
||||||
|
.pipe(
|
||||||
|
finalize(() => {
|
||||||
|
this.onComplete.emit();
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.subscribe(([profileResult, infoResult]) => {});
|
.subscribe(([profileResult, infoResult]) => {});
|
||||||
|
|||||||
Reference in New Issue
Block a user