From 1886b3411c69d8eb4fffbbfe29eb3a917d04e2f4 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 26 Aug 2020 01:19:21 +0800 Subject: No longer wait for saving user, which may lead to delay. --- Timeline/ClientApp/src/app/data/timeline.ts | 6 +++--- Timeline/ClientApp/src/app/data/user.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'Timeline/ClientApp') diff --git a/Timeline/ClientApp/src/app/data/timeline.ts b/Timeline/ClientApp/src/app/data/timeline.ts index 0e11b4e7..3eda35f9 100644 --- a/Timeline/ClientApp/src/app/data/timeline.ts +++ b/Timeline/ClientApp/src/app/data/timeline.ts @@ -152,7 +152,7 @@ export class TimelineService { try { const httpTimeline = await getHttpTimelineClient().getTimeline(key); - await userInfoService.saveUsers([ + userInfoService.saveUsers([ httpTimeline.owner, ...httpTimeline.members, ]); @@ -339,7 +339,7 @@ export class TimelineService { userService.currentUser?.token ); - await userInfoService.saveUsers( + userInfoService.saveUsers( uniqBy( httpPosts.map((post) => post.author), "username" @@ -368,7 +368,7 @@ export class TimelineService { (p): p is HttpTimelinePostInfo => !p.deleted ); - await userInfoService.saveUsers( + userInfoService.saveUsers( uniqBy( httpPosts .map((post) => post.author) diff --git a/Timeline/ClientApp/src/app/data/user.ts b/Timeline/ClientApp/src/app/data/user.ts index 66fcd83c..b8f163eb 100644 --- a/Timeline/ClientApp/src/app/data/user.ts +++ b/Timeline/ClientApp/src/app/data/user.ts @@ -226,16 +226,16 @@ export function checkLogin(): UserWithToken { export class UserNotExistError extends Error {} export class UserInfoService { - saveUser(user: HttpUser): Promise { + saveUser(user: HttpUser): void { const key = user.username; - return this._userHub.optionalInitLineWithSyncAction(key, async (line) => { + void this._userHub.optionalInitLineWithSyncAction(key, async (line) => { await this.doSaveUser(user); line.next({ user, type: "synced" }); }); } - saveUsers(users: HttpUser[]): Promise { - return Promise.all(users.map((user) => this.saveUser(user))).then(); + saveUsers(users: HttpUser[]): void { + return users.forEach((user) => this.saveUser(user)); } private getCachedUser(username: string): Promise { @@ -364,7 +364,7 @@ export class UserInfoService { return getHttpUserClient() .patch(username, { nickname }, user.token) .then((user) => { - void this.saveUser(user); + this.saveUser(user); }); } } -- cgit v1.2.3