Skip to content

Commit

Permalink
Fix: Introduction tour start after guest login
Browse files Browse the repository at this point in the history
  • Loading branch information
SecSimon committed May 26, 2023
1 parent 3272039 commit d7872ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ <h2>
<h2>{{'pages.home.welcome' | translate}}!</h2>
<p>{{'pages.home.need_login' | translate}}:</p>
<button mat-button routerLink="/login">{{'pages.home.go_to_login' | translate}}</button>
<button mat-button (click)="dataService.GuestLogin()">{{'pages.login.loginAsGuest' | translate}}</button>
<button mat-button (click)="dataService.GuestLogin(); CheckTourStart()">{{'pages.login.loginAsGuest' | translate}}</button>
</ng-container>
</div>
</div>
Expand Down
34 changes: 19 additions & 15 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class HomeComponent implements OnInit {
}

ngOnInit(): void {
let createStep = (anchor: string) => {
const createStep = (anchor: string) => {
return {
anchorId: anchor,
content: this.translate.instant('tour.' + anchor + '.content'),
Expand All @@ -60,38 +60,32 @@ export class HomeComponent implements OnInit {
}

this.translate.get('tour.change-settings.title').subscribe(() => {
const startTourGetConsent = () => {
const getConsentInitTour = () => {
this.tourService.initialize([
createStep('change-settings'),
createStep('message-history'),
createStep('save-file'),
createStep('set-progress')
]);

if ([UserModes.LoggedIn, UserModes.Guest].includes(this.dataService.UserMode)) {
let wcs = this.locStorage.Get(LocStorageKeys.WELCOME_TOUR_STARTED);
if (!wcs) {
this.tourService.start();
this.locStorage.Set(LocStorageKeys.WELCOME_TOUR_STARTED, JSON.stringify(true));
}
}

let consent = this.locStorage.Get(LocStorageKeys.COOKIE_CONSENT);
if (consent == null) this.dialogService.OpenCookieConsentDialog();
const consent = this.locStorage.Get(LocStorageKeys.COOKIE_CONSENT);
if (consent == null) this.dialogService.OpenCookieConsentDialog().subscribe(x => this.CheckTourStart());
else this.CheckTourStart();
};

// wait until translate service is available
let lang = this.locStorage.Get(LocStorageKeys.LANGUAGE);
const lang = this.locStorage.Get(LocStorageKeys.LANGUAGE);
if (!lang || lang.length == 0) {
// this.dialog.open(WelcomeDialogComponent);
// skip welcome, set language
// if ((navigator.language || navigator.languages).includes('de')) this.locStorage.Set(LocStorageKeys.LANGUAGE, 'de');
// else this.locStorage.Set(LocStorageKeys.LANGUAGE, 'en');
this.dialog.open(LanguageDialogComponent).afterClosed().subscribe(x => {
startTourGetConsent();
getConsentInitTour();
});
}
else {
startTourGetConsent();
getConsentInitTour();
}
});

Expand All @@ -111,6 +105,16 @@ export class HomeComponent implements OnInit {
this.dataService.ProjectChanged.subscribe(x => this.router.navigate(['/' + dest]));
}

public CheckTourStart() {
if ([UserModes.LoggedIn, UserModes.Guest].includes(this.dataService.UserMode)) {
const wcs = this.locStorage.Get(LocStorageKeys.WELCOME_TOUR_STARTED);
if (!wcs) {
this.tourService.start();
this.locStorage.Set(LocStorageKeys.WELCOME_TOUR_STARTED, JSON.stringify(true));
}
}
}

public GetRepoName(file) {
return this.dataService.GetRepoOfFile(file)?.name;
}
Expand Down

0 comments on commit d7872ec

Please sign in to comment.