From 9d421cf555774e437f156347c0502170f475c544 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 8 Aug 2020 18:06:35 +0800 Subject: Remove queue. --- Timeline/ClientApp/src/app/data/queue.ts | 14 -------------- Timeline/ClientApp/src/app/data/timeline.ts | 22 ++-------------------- Timeline/ClientApp/src/app/data/user.ts | 9 --------- 3 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 Timeline/ClientApp/src/app/data/queue.ts (limited to 'Timeline/ClientApp/src') 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>(); - -export function queue(key: string, func: () => Promise): Promise { - 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 { - return queue(`TimelineService.fetchAndCacheTimeline.${timelineName}`, () => - this.doFetchAndCacheTimeline(timelineName) - ); - } - - private async doFetchAndCacheTimeline( + private async fetchAndCacheTimeline( timelineName: string ): Promise { try { @@ -337,16 +328,7 @@ export class TimelineService { return posts; } - private fetchAndCachePosts( - timelineName: string, - notUseDataCache = false - ): Promise { - return queue(`TimelineService.fetchAndCachePosts.${timelineName}`, () => - this.doFetchAndCachePosts(timelineName, notUseDataCache) - ); - } - - private async doFetchAndCachePosts( + private async fetchAndCachePosts( timelineName: string, notUseDataCache = false ): Promise { 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 { @@ -239,14 +238,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(key); -- cgit v1.2.3