diff options
author | crupest <crupest@outlook.com> | 2021-01-12 22:09:34 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-12 22:09:34 +0800 |
commit | 2dbddec6a0419def50efd8136f1cab5dc35fcff3 (patch) | |
tree | ff96566f05dea350277fab978b5deef60db283fe /FrontEnd/src/app/services/timeline.ts | |
parent | 07eb0d4d777c36da7ea62ea55a2ac3f68e899694 (diff) | |
download | timeline-2dbddec6a0419def50efd8136f1cab5dc35fcff3.tar.gz timeline-2dbddec6a0419def50efd8136f1cab5dc35fcff3.tar.bz2 timeline-2dbddec6a0419def50efd8136f1cab5dc35fcff3.zip |
...
Diffstat (limited to 'FrontEnd/src/app/services/timeline.ts')
-rw-r--r-- | FrontEnd/src/app/services/timeline.ts | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/FrontEnd/src/app/services/timeline.ts b/FrontEnd/src/app/services/timeline.ts index 4e2530cc..46671ea1 100644 --- a/FrontEnd/src/app/services/timeline.ts +++ b/FrontEnd/src/app/services/timeline.ts @@ -26,6 +26,8 @@ export type { TimelineVisibility } from "@/http/timeline"; import { dataStorage } from "./common"; import { userInfoService, AuthUser } from "./user"; import { DataAndStatus, DataHub2 } from "./DataHub2"; +import { getHttpBookmarkClient } from "@/http/bookmark"; +import { getHttpHighlightClient } from "@/http/highlight"; export type TimelineInfo = HttpTimelineInfo; export type TimelineChangePropertyRequest = HttpTimelinePatchRequest; @@ -347,24 +349,20 @@ export class TimelineService { createPost( timelineName: string, request: TimelineCreatePostRequest - ): Observable<unknown> { - return from( - getHttpTimelineClient() - .postPost(timelineName, request) - .then(() => { - void this.syncPosts(timelineName); - }) - ); + ): Promise<void> { + return getHttpTimelineClient() + .postPost(timelineName, request) + .then(() => { + void this.syncPosts(timelineName); + }); } - deletePost(timelineName: string, postId: number): Observable<unknown> { - return from( - getHttpTimelineClient() - .deletePost(timelineName, postId) - .then(() => { - void this.syncPosts(timelineName); - }) - ); + deletePost(timelineName: string, postId: number): Promise<void> { + return getHttpTimelineClient() + .deletePost(timelineName, postId) + .then(() => { + void this.syncPosts(timelineName); + }); } isMemberOf(username: string, timeline: TimelineInfo): boolean { @@ -433,6 +431,26 @@ export class TimelineService { user.username === post.author.username) ); } + + setHighlight(timelineName: string, highlight: boolean): Promise<void> { + const client = getHttpHighlightClient(); + const promise = highlight + ? client.put(timelineName) + : client.delete(timelineName); + return promise.then(() => { + void timelineService.syncTimeline(timelineName); + }); + } + + setBookmark(timelineName: string, bookmark: boolean): Promise<void> { + const client = getHttpBookmarkClient(); + const promise = bookmark + ? client.put(timelineName) + : client.delete(timelineName); + return promise.then(() => { + void timelineService.syncTimeline(timelineName); + }); + } } export const timelineService = new TimelineService(); |