aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-08-08 18:06:35 +0800
committercrupest <crupest@outlook.com>2020-08-08 18:06:35 +0800
commit85f3255f943a0420c9d6a2a519a3eb64669b00f4 (patch)
treeea871c2bd119dac752b0d6944df3a34c3b6703b4
parentdde84402e7b56de3ed7b487c2cfb4d943bff42e9 (diff)
downloadtimeline-85f3255f943a0420c9d6a2a519a3eb64669b00f4.tar.gz
timeline-85f3255f943a0420c9d6a2a519a3eb64669b00f4.tar.bz2
timeline-85f3255f943a0420c9d6a2a519a3eb64669b00f4.zip
Remove queue.
-rw-r--r--Timeline/ClientApp/src/app/data/queue.ts14
-rw-r--r--Timeline/ClientApp/src/app/data/timeline.ts22
-rw-r--r--Timeline/ClientApp/src/app/data/user.ts9
3 files changed, 2 insertions, 43 deletions
diff --git a/Timeline/ClientApp/src/app/data/queue.ts b/Timeline/ClientApp/src/app/data/queue.ts
deleted file mode 100644
index 001340a9..00000000
--- a/Timeline/ClientApp/src/app/data/queue.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-const queueMap = new Map<string, Promise<null>>();
-
-export function queue<T>(key: string, func: () => Promise<T>): Promise<T> {
- const last = queueMap.get(key);
- if (last == null) {
- const promise = func();
- queueMap.set(key, promise.then(null, null));
- return promise;
- } else {
- const promise = last.then(() => func());
- queueMap.set(key, promise.then(null, null));
- return promise;
- }
-}
diff --git a/Timeline/ClientApp/src/app/data/timeline.ts b/Timeline/ClientApp/src/app/data/timeline.ts
index 51cc37e6..fa019adb 100644
--- a/Timeline/ClientApp/src/app/data/timeline.ts
+++ b/Timeline/ClientApp/src/app/data/timeline.ts
@@ -6,7 +6,6 @@ import { map } from 'rxjs/operators';
import { convertError } from '../utilities/rxjs';
import { dataStorage } from './common';
-import { queue } from './queue';
import { SubscriptionHub, ISubscriptionHub } from './SubscriptionHub';
import { UserAuthInfo, checkLogin, userService, userInfoService } from './user';
@@ -121,15 +120,7 @@ export class TimelineService {
);
}
- private fetchAndCacheTimeline(
- timelineName: string
- ): Promise<FetchAndCacheTimelineResult> {
- return queue(`TimelineService.fetchAndCacheTimeline.${timelineName}`, () =>
- this.doFetchAndCacheTimeline(timelineName)
- );
- }
-
- private async doFetchAndCacheTimeline(
+ private async fetchAndCacheTimeline(
timelineName: string
): Promise<FetchAndCacheTimelineResult> {
try {
@@ -337,16 +328,7 @@ export class TimelineService {
return posts;
}
- private fetchAndCachePosts(
- timelineName: string,
- notUseDataCache = false
- ): Promise<FetchAndCachePostsResult> {
- return queue(`TimelineService.fetchAndCachePosts.${timelineName}`, () =>
- this.doFetchAndCachePosts(timelineName, notUseDataCache)
- );
- }
-
- private async doFetchAndCachePosts(
+ private async fetchAndCachePosts(
timelineName: string,
notUseDataCache = false
): Promise<FetchAndCachePostsResult> {
diff --git a/Timeline/ClientApp/src/app/data/user.ts b/Timeline/ClientApp/src/app/data/user.ts
index 1d2d6f88..8b299c38 100644
--- a/Timeline/ClientApp/src/app/data/user.ts
+++ b/Timeline/ClientApp/src/app/data/user.ts
@@ -7,7 +7,6 @@ import { pushAlert } from '../common/alert-service';
import { dataStorage } from './common';
import { SubscriptionHub, ISubscriptionHub } from './SubscriptionHub';
-import { queue } from './queue';
import { HttpNetworkError, BlobWithEtag, NotModified } from '../http/common';
import {
@@ -240,14 +239,6 @@ export class UserInfoService {
private async fetchAndCacheAvatar(
username: string
): Promise<{ data: Blob; type: 'synced' | 'cache' } | 'offline'> {
- return queue(`UserService.fetchAndCacheAvatar.${username}`, () =>
- this.doFetchAndCacheAvatar(username)
- );
- }
-
- private async doFetchAndCacheAvatar(
- username: string
- ): Promise<{ data: Blob; type: 'synced' | 'cache' } | 'offline'> {
const key = this.getAvatarKey(username);
const cache = await dataStorage.getItem<BlobWithEtag | null>(key);
if (cache == null) {