Skip to content

Commit

Permalink
Don't display account setup modal on signup
Browse files Browse the repository at this point in the history
Don't bother user with a modal just after signup
  • Loading branch information
Chocobozzz committed Aug 27, 2021
1 parent e111a5a commit bf80903
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion client/src/app/core/users/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SortMeta } from 'primeng/api'
import { from, Observable, of } from 'rxjs'
import { catchError, concatMap, filter, first, map, shareReplay, throttleTime, toArray } from 'rxjs/operators'
import { catchError, concatMap, filter, first, map, shareReplay, tap, throttleTime, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { AuthService } from '@app/core/auth'
Expand Down Expand Up @@ -28,6 +28,8 @@ export class UserService {

private userCache: { [ id: number ]: Observable<UserServerModel> } = {}

private signupInThisSession = false

constructor (
private authHttp: HttpClient,
private authService: AuthService,
Expand All @@ -37,6 +39,10 @@ export class UserService {
private sessionStorageService: SessionStorageService
) { }

hasSignupInThisSession () {
return this.signupInThisSession
}

changePassword (currentPassword: string, newPassword: string) {
const url = UserService.BASE_USERS_URL + 'me'
const body: UserUpdateMe = {
Expand Down Expand Up @@ -153,6 +159,7 @@ export class UserService {
return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
.pipe(
map(this.restExtractor.extractDataBool),
tap(() => this.signupInThisSession = true),
catchError(err => this.restExtractor.handleError(err))
)
}
Expand Down
10 changes: 6 additions & 4 deletions client/src/app/modal/account-setup-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { AuthService, ServerService, User } from '@app/core'
import { AuthService, ServerService, User, UserService } from '@app/core'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig } from '@shared/models'

Expand All @@ -17,6 +17,7 @@ export class AccountSetupModalComponent implements OnInit {
private serverConfig: HTMLServerConfig

constructor (
private userService: UserService,
private authService: AuthService,
private modalService: NgbModal,
private serverService: ServerService
Expand Down Expand Up @@ -49,16 +50,17 @@ export class AccountSetupModalComponent implements OnInit {
this.authService.userInformationLoaded
.subscribe(
() => {
if (this.isUserRoot) return false
if (this.hasAccountAvatar && this.hasAccountDescription) return false
if (this.isUserRoot) return
if (this.hasAccountAvatar && this.hasAccountDescription) return
if (this.userService.hasSignupInThisSession()) return

this.show()
}
)
}

show () {
if (this.ref) return false
if (this.ref) return

this.ref = this.modalService.open(this.modal, {
centered: true,
Expand Down

0 comments on commit bf80903

Please sign in to comment.