diff options
author | crupest <crupest@outlook.com> | 2020-07-27 18:18:20 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-07-27 18:18:20 +0800 |
commit | 0863e0d139f12c444a2a01bb899bc3148c52e7ce (patch) | |
tree | b1f7833d3ccf5b7419c824ea2d5b34e546d66755 /Timeline/ClientApp/src/app/data/timeline.ts | |
parent | c10218d8d5ec01ae29c0b2880a8d6af371a562e5 (diff) | |
download | timeline-0863e0d139f12c444a2a01bb899bc3148c52e7ce.tar.gz timeline-0863e0d139f12c444a2a01bb899bc3148c52e7ce.tar.bz2 timeline-0863e0d139f12c444a2a01bb899bc3148c52e7ce.zip |
Refactor SubscriptionHub.
Diffstat (limited to 'Timeline/ClientApp/src/app/data/timeline.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/data/timeline.ts | 15 |
1 files changed, 10 insertions, 5 deletions
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<PostKey, BlobWithUrl>(
+ 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<PostKey, BlobWithUrl> {
+ get postDataHub(): ISubscriptionHub<PostKey, BlobWithUrl | null> {
return this._postDataSubscriptionHub;
}
@@ -275,8 +280,8 @@ export function usePostDataUrl( timelineName,
postId,
},
- ({ url }) => {
- setUrl(url);
+ (data) => {
+ setUrl(data?.url);
}
);
return () => {
|