Don't display account setup modal on signup

Don't bother user with a modal just after signup
pull/4360/head
Chocobozzz 2021-08-27 09:26:45 +02:00
parent e111a5a3a1
commit bf80903fde
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { SortMeta } from 'primeng/api' import { SortMeta } from 'primeng/api'
import { from, Observable, of } from 'rxjs' 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 { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { AuthService } from '@app/core/auth' import { AuthService } from '@app/core/auth'
@ -28,6 +28,8 @@ export class UserService {
private userCache: { [ id: number ]: Observable<UserServerModel> } = {} private userCache: { [ id: number ]: Observable<UserServerModel> } = {}
private signupInThisSession = false
constructor ( constructor (
private authHttp: HttpClient, private authHttp: HttpClient,
private authService: AuthService, private authService: AuthService,
@ -37,6 +39,10 @@ export class UserService {
private sessionStorageService: SessionStorageService private sessionStorageService: SessionStorageService
) { } ) { }
hasSignupInThisSession () {
return this.signupInThisSession
}
changePassword (currentPassword: string, newPassword: string) { changePassword (currentPassword: string, newPassword: string) {
const url = UserService.BASE_USERS_URL + 'me' const url = UserService.BASE_USERS_URL + 'me'
const body: UserUpdateMe = { const body: UserUpdateMe = {
@ -153,6 +159,7 @@ export class UserService {
return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
.pipe( .pipe(
map(this.restExtractor.extractDataBool), map(this.restExtractor.extractDataBool),
tap(() => this.signupInThisSession = true),
catchError(err => this.restExtractor.handleError(err)) catchError(err => this.restExtractor.handleError(err))
) )
} }

View File

@ -1,5 +1,5 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' 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 { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { HTMLServerConfig } from '@shared/models' import { HTMLServerConfig } from '@shared/models'
@ -17,6 +17,7 @@ export class AccountSetupModalComponent implements OnInit {
private serverConfig: HTMLServerConfig private serverConfig: HTMLServerConfig
constructor ( constructor (
private userService: UserService,
private authService: AuthService, private authService: AuthService,
private modalService: NgbModal, private modalService: NgbModal,
private serverService: ServerService private serverService: ServerService
@ -49,8 +50,9 @@ export class AccountSetupModalComponent implements OnInit {
this.authService.userInformationLoaded this.authService.userInformationLoaded
.subscribe( .subscribe(
() => { () => {
if (this.isUserRoot) return false if (this.isUserRoot) return
if (this.hasAccountAvatar && this.hasAccountDescription) return false if (this.hasAccountAvatar && this.hasAccountDescription) return
if (this.userService.hasSignupInThisSession()) return
this.show() this.show()
} }
@ -58,7 +60,7 @@ export class AccountSetupModalComponent implements OnInit {
} }
show () { show () {
if (this.ref) return false if (this.ref) return
this.ref = this.modalService.open(this.modal, { this.ref = this.modalService.open(this.modal, {
centered: true, centered: true,