diff --git a/src/ui/quickTour/quickTour.service.ts b/src/ui/quickTour/quickTour.service.ts index 78bd0c164431b0b40c119cbce56f6380eaec28a4..afff396275bb07eefe28a6b5e089ce5a3646ca42 100644 --- a/src/ui/quickTour/quickTour.service.ts +++ b/src/ui/quickTour/quickTour.service.ts @@ -5,6 +5,7 @@ import { ComponentPortal } from "@angular/cdk/portal"; import { QuickTourThis } from "./quickTourThis.directive"; import { DoublyLinkedList, IDoublyLinkedItem } from 'src/util' import { QUICK_TOUR_CMP_INJTKN } from "./constrants"; +import {LOCAL_STORAGE_CONST} from "src/util/constants"; export function findInLinkedList<T extends object>(first: IDoublyLinkedItem<T>, predicate: (linkedObj: IDoublyLinkedItem<T>) => boolean): IDoublyLinkedItem<T>{ let compareObj = first, @@ -62,6 +63,13 @@ export class QuickTourService { this.slides.remove(dir) } + public autoStart() { + if (!localStorage.getItem(LOCAL_STORAGE_CONST.QUICK_TOUR_VIEWED)) { + this.startTour() + localStorage.setItem(LOCAL_STORAGE_CONST.QUICK_TOUR_VIEWED, 'true') + } + } + public startTour() { if (!this.overlayRef) { this.overlayRef = this.overlay.create({ @@ -70,14 +78,14 @@ export class QuickTourService { hasBackdrop: true, backdropClass: ['pe-none', 'cdk-overlay-dark-backdrop'], positionStrategy: this.overlay.position().global(), - }) + }) } - + if (!this.cmpRef) { this.cmpRef = this.overlayRef.attach( new ComponentPortal(this.quickTourCmp) ) - + this.currActiveSlide = this.slides.first this.currentTip$.next(this.currActiveSlide) } diff --git a/src/ui/quickTour/quickTourThis.directive.ts b/src/ui/quickTour/quickTourThis.directive.ts index b7ccf2c7b4692a289c08f7feb702f88b999d4379..d90ab88498f65c22b335d883578a9ed1dcc33d4a 100644 --- a/src/ui/quickTour/quickTourThis.directive.ts +++ b/src/ui/quickTour/quickTourThis.directive.ts @@ -33,10 +33,7 @@ export class QuickTourThis implements OnInit, OnChanges, OnDestroy { this.quickTourService.register(this) if (this.quickTourCheckAutoStart) { - if (!localStorage.getItem(LOCAL_STORAGE_CONST.QUICK_TOUR_VIEWED)) { - this.quickTourService.startTour() - localStorage.setItem(LOCAL_STORAGE_CONST.QUICK_TOUR_VIEWED, 'true') - } + this.quickTourService.autoStart() } }