aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/users/user.service.ts14
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html7
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts2
3 files changed, 17 insertions, 6 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index 051e0bfa4..e24d91df3 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -1,5 +1,5 @@
1import { from, Observable } from 'rxjs' 1import { from, Observable, of } from 'rxjs'
2import { catchError, concatMap, map, toArray } from 'rxjs/operators' 2import { catchError, concatMap, map, share, shareReplay, tap, toArray } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { ResultList, User, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' 5import { ResultList, User, UserCreate, UserRole, UserUpdate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
@@ -17,6 +17,8 @@ export class UserService {
17 17
18 private bytesPipe = new BytesPipe() 18 private bytesPipe = new BytesPipe()
19 19
20 private userCache: { [ id: number ]: Observable<User> } = {}
21
20 constructor ( 22 constructor (
21 private authHttp: HttpClient, 23 private authHttp: HttpClient,
22 private restExtractor: RestExtractor, 24 private restExtractor: RestExtractor,
@@ -194,6 +196,14 @@ export class UserService {
194 ) 196 )
195 } 197 }
196 198
199 getUserWithCache (userId: number) {
200 if (!this.userCache[userId]) {
201 this.userCache[ userId ] = this.getUser(userId).pipe(shareReplay())
202 }
203
204 return this.userCache[userId]
205 }
206
197 getUser (userId: number) { 207 getUser (userId: number) {
198 return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId) 208 return this.authHttp.get<User>(UserService.BASE_USERS_URL + userId)
199 .pipe(catchError(err => this.restExtractor.handleError(err))) 209 .pipe(catchError(err => this.restExtractor.handleError(err)))
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html
index 4753641bd..246a08435 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html
@@ -36,8 +36,9 @@
36 <div class="comment-actions"> 36 <div class="comment-actions">
37 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div> 37 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div>
38 <div *ngIf="isRemovableByUser()" (click)="onWantToDelete()" class="comment-action-delete" i18n>Delete</div> 38 <div *ngIf="isRemovableByUser()" (click)="onWantToDelete()" class="comment-action-delete" i18n>Delete</div>
39
39 <my-user-moderation-dropdown 40 <my-user-moderation-dropdown
40 buttonSize="small" [account]="commentAccount" [user]="commentUser" label="Options" placement="bottom-left auto" 41 buttonSize="small" [account]="commentAccount" [user]="commentUser" i18n-label label="Options" placement="bottom-left auto"
41 ></my-user-moderation-dropdown> 42 ></my-user-moderation-dropdown>
42 </div> 43 </div>
43 </ng-container> 44 </ng-container>
@@ -80,8 +81,8 @@
80 ></my-video-comment> 81 ></my-video-comment>
81 </div> 82 </div>
82 </div> 83 </div>
83 </div>
84 84
85 <ng-content></ng-content> 85 <ng-content></ng-content>
86 </div>
86 </div> 87 </div>
87</div> 88</div>
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
index 8c376d654..0c18b6e5d 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
@@ -107,7 +107,7 @@ export class VideoCommentComponent implements OnInit, OnChanges {
107 107
108 const user = this.authService.getUser() 108 const user = this.authService.getUser()
109 if (user.hasRight(UserRight.MANAGE_USERS)) { 109 if (user.hasRight(UserRight.MANAGE_USERS)) {
110 this.userService.getUser(account.userId) 110 this.userService.getUserWithCache(account.userId)
111 .subscribe( 111 .subscribe(
112 user => this.commentUser = user, 112 user => this.commentUser = user,
113 113