aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/data/timeline.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-07-27 18:18:20 +0800
committercrupest <crupest@outlook.com>2020-07-27 18:18:20 +0800
commit1e694d892eac5817da9778c50fd2c7113177b7e9 (patch)
tree8c6d265d29d38b403fd75034866df85e38481412 /Timeline/ClientApp/src/app/data/timeline.ts
parent328036901d825179b6e916ee9d79e9396cf982d4 (diff)
downloadtimeline-1e694d892eac5817da9778c50fd2c7113177b7e9.tar.gz
timeline-1e694d892eac5817da9778c50fd2c7113177b7e9.tar.bz2
timeline-1e694d892eac5817da9778c50fd2c7113177b7e9.zip
Refactor SubscriptionHub.
Diffstat (limited to 'Timeline/ClientApp/src/app/data/timeline.ts')
-rw-r--r--Timeline/ClientApp/src/app/data/timeline.ts15
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 () => {