aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-08-26 01:19:21 +0800
committercrupest <crupest@outlook.com>2020-08-26 01:19:21 +0800
commitb2404a381178e962a09af018d3c0031f1918991a (patch)
tree6e20871c99c93b1054799bc6b46681d2b6f1547e /Timeline/ClientApp/src
parent9f8c232ef942a070d4449b9d7f075ff66aa2a0c8 (diff)
downloadtimeline-b2404a381178e962a09af018d3c0031f1918991a.tar.gz
timeline-b2404a381178e962a09af018d3c0031f1918991a.tar.bz2
timeline-b2404a381178e962a09af018d3c0031f1918991a.zip
No longer wait for saving user, which may lead to delay.
Diffstat (limited to 'Timeline/ClientApp/src')
-rw-r--r--Timeline/ClientApp/src/app/data/timeline.ts6
-rw-r--r--Timeline/ClientApp/src/app/data/user.ts10
2 files changed, 8 insertions, 8 deletions
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<void> {
+ 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<void> {
- 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<User | null> {
@@ -364,7 +364,7 @@ export class UserInfoService {
return getHttpUserClient()
.patch(username, { nickname }, user.token)
.then((user) => {
- void this.saveUser(user);
+ this.saveUser(user);
});
}
}