From 0863e0d139f12c444a2a01bb899bc3148c52e7ce Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 27 Jul 2020 18:18:20 +0800 Subject: Refactor SubscriptionHub. --- Timeline/ClientApp/src/app/data/timeline.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Timeline/ClientApp/src/app/data/timeline.ts') diff --git a/Timeline/ClientApp/src/app/data/timeline.ts b/Timeline/ClientApp/src/app/data/timeline.ts index f2c3fdda..7ade8f56 100644 --- a/Timeline/ClientApp/src/app/data/timeline.ts +++ b/Timeline/ClientApp/src/app/data/timeline.ts @@ -131,6 +131,7 @@ export class TimelineService { TimelinePostInfo[] >( (key) => key, + () => [], async (key) => { return ( await getHttpTimelineClient().listPost( @@ -148,8 +149,12 @@ export class TimelineService { return this._postListSubscriptionHub; } - private _postDataSubscriptionHub = new SubscriptionHub( + private _postDataSubscriptionHub = new SubscriptionHub< + PostKey, + BlobWithUrl | null + >( (key) => `${key.timelineName}/${key.postId}`, + () => null, async (key) => { const blob = ( await getHttpTimelineClient().getPostData( @@ -165,11 +170,11 @@ export class TimelineService { }; }, (_key, data) => { - URL.revokeObjectURL(data.url); + if (data != null) URL.revokeObjectURL(data.url); } ); - get postDataHub(): ISubscriptionHub { + get postDataHub(): ISubscriptionHub { return this._postDataSubscriptionHub; } @@ -275,8 +280,8 @@ export function usePostDataUrl( timelineName, postId, }, - ({ url }) => { - setUrl(url); + (data) => { + setUrl(data?.url); } ); return () => { -- cgit v1.2.3