2026-05-11 18:42:05 +03:30
|
|
|
import { PwaInstallService } from '@/core/services';
|
2026-05-11 13:36:06 +03:30
|
|
|
import { Component, EventEmitter, inject, Output } from '@angular/core';
|
2026-05-11 18:42:05 +03:30
|
|
|
import { ButtonDirective } from 'primeng/button';
|
2026-05-11 13:36:06 +03:30
|
|
|
import { finalize, forkJoin } from 'rxjs';
|
|
|
|
|
import images from 'src/assets/images';
|
|
|
|
|
import { PosInfoStore, PosProfileStore } from '../store';
|
|
|
|
|
import { DeviceInfoStore } from '../store/device.store';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'pos-splash',
|
|
|
|
|
templateUrl: 'splash.component.html',
|
2026-05-11 18:42:05 +03:30
|
|
|
imports: [ButtonDirective],
|
2026-05-11 13:36:06 +03:30
|
|
|
})
|
|
|
|
|
export class PosSplashComponent {
|
|
|
|
|
@Output() onComplete = new EventEmitter<void>();
|
|
|
|
|
|
|
|
|
|
private readonly posProfileStore = inject(PosProfileStore);
|
|
|
|
|
private readonly posInfoStore = inject(PosInfoStore);
|
|
|
|
|
private readonly deviceInfoStore = inject(DeviceInfoStore);
|
2026-05-11 18:42:05 +03:30
|
|
|
private readonly pwaInstallService = inject(PwaInstallService);
|
2026-05-11 13:36:06 +03:30
|
|
|
|
|
|
|
|
logo = images.logo;
|
2026-05-11 18:42:05 +03:30
|
|
|
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;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (this.canInstall()) {
|
|
|
|
|
// this.installPromptShown = true;
|
|
|
|
|
// this.pwaInstallService.openInstallConfirm();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
2026-05-11 13:36:06 +03:30
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
|
const data = await this.deviceInfoStore.getData();
|
|
|
|
|
const profileObs = await this.posProfileStore.getData();
|
|
|
|
|
const infoObs = await this.posInfoStore.getData();
|
|
|
|
|
|
|
|
|
|
forkJoin([profileObs, infoObs])
|
|
|
|
|
.pipe(
|
|
|
|
|
finalize(() => {
|
2026-05-11 18:42:05 +03:30
|
|
|
if (!this.requireInstall || this.pwaInstalled()) {
|
|
|
|
|
this.onComplete.emit();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.canInstall()) {
|
|
|
|
|
this.pwaInstallService.openInstallConfirm();
|
|
|
|
|
this.installPromptShown = true;
|
|
|
|
|
}
|
2026-05-11 13:36:06 +03:30
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.subscribe(([profileResult, infoResult]) => {});
|
|
|
|
|
}
|
2026-05-11 18:42:05 +03:30
|
|
|
|
|
|
|
|
installPwa() {
|
|
|
|
|
this.pwaInstallService.openInstallConfirm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continueAfterInstall() {
|
|
|
|
|
if (this.pwaInstalled()) {
|
|
|
|
|
this.onComplete.emit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-11 13:36:06 +03:30
|
|
|
}
|