]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/users/user.service.ts
Don't display account setup modal on signup
[github/Chocobozzz/PeerTube.git] / client / src / app / core / users / user.service.ts
index 16ea8aa1a20a33bec15d2ca4dd291a00f231b9a4..be9e66c3c705f091371ab48375124b16c6f7d332 100644 (file)
@@ -1,14 +1,13 @@
 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'
 import { getBytes } from '@root-helpers/bytes'
 import { UserLocalStorageKeys } from '@root-helpers/users'
 import {
-  Avatar,
-  NSFWPolicyType,
+  ActorImage,
   ResultList,
   User as UserServerModel,
   UserCreate,
@@ -29,6 +28,8 @@ export class UserService {
 
   private userCache: { [ id: number ]: Observable<UserServerModel> } = {}
 
+  private signupInThisSession = false
+
   constructor (
     private authHttp: HttpClient,
     private authService: AuthService,
@@ -36,7 +37,11 @@ export class UserService {
     private restService: RestService,
     private localStorageService: LocalStorageService,
     private sessionStorageService: SessionStorageService
-    ) { }
+  ) { }
+
+  hasSignupInThisSession () {
+    return this.signupInThisSession
+  }
 
   changePassword (currentPassword: string, newPassword: string) {
     const url = UserService.BASE_USERS_URL + 'me'
@@ -92,7 +97,7 @@ export class UserService {
 
     for (const [ key, value ] of obj) {
       try {
-        if (!value) {
+        if (value === undefined) {
           this.localStorageService.removeItem(key)
           continue
         }
@@ -136,7 +141,7 @@ export class UserService {
   changeAvatar (avatarForm: FormData) {
     const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
 
-    return this.authHttp.post<{ avatar: Avatar }>(url, avatarForm)
+    return this.authHttp.post<{ avatar: ActorImage }>(url, avatarForm)
                .pipe(catchError(err => this.restExtractor.handleError(err)))
   }
 
@@ -154,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))
                )
   }
@@ -267,7 +273,7 @@ export class UserService {
 
   getUserWithCache (userId: number) {
     if (!this.userCache[userId]) {
-      this.userCache[ userId ] = this.getUser(userId).pipe(shareReplay())
+      this.userCache[userId] = this.getUser(userId).pipe(shareReplay())
     }
 
     return this.userCache[userId]
@@ -321,13 +327,7 @@ export class UserService {
       const filters = this.restService.parseQueryStringFilter(search, {
         blocked: {
           prefix: 'banned:',
-          isBoolean: true,
-          handler: v => {
-            if (v === 'true') return v
-            if (v === 'false') return v
-
-            return undefined
-          }
+          isBoolean: true
         }
       })