diff options
author | crupest <crupest@outlook.com> | 2021-01-09 23:30:39 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-09 23:30:39 +0800 |
commit | 8b0f3472b3023fb62126be90575259aae23eda79 (patch) | |
tree | dcb485b37f87a79d17144a6ea977ebbaea918424 /FrontEnd/src/app/views | |
parent | 2207772bf34fe1e4d54627c5800307bf121e0ad8 (diff) | |
download | timeline-8b0f3472b3023fb62126be90575259aae23eda79.tar.gz timeline-8b0f3472b3023fb62126be90575259aae23eda79.tar.bz2 timeline-8b0f3472b3023fb62126be90575259aae23eda79.zip |
...
Diffstat (limited to 'FrontEnd/src/app/views')
-rw-r--r-- | FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index e0ad002a..35b31ec2 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -143,7 +143,7 @@ export default function TimelinePageTemplate<TManageItem>( type: "i18n", key: isBookmark ? "timeline.removeBookmarkFail" - : "timeline.addBookmarkFail", // TODO: Add this translation. + : "timeline.addBookmarkFail", }, type: "danger", }); @@ -155,17 +155,35 @@ export default function TimelinePageTemplate<TManageItem>( onHighlight: user != null && user.hasHighlightTimelineAdministrationPermission ? () => { - void getHttpHighlightClient() - .put(name) - .then(() => { + const { isHighlight } = timeline; + setTimelineState({ + ...timelineState, + timeline: { + ...timeline, + isHighlight: !isHighlight, + }, + }); + const client = getHttpHighlightClient(); + const promise = isHighlight + ? client.delete(name) + : client.put(name); + promise.then( + () => { + void timelineService.syncTimeline(name); + }, + () => { pushAlert({ message: { type: "i18n", - key: "timeline.addHighlightSuccess", + key: isHighlight + ? "timeline.removeHighlightFail" + : "timeline.addHighlightFail", }, - type: "success", + type: "danger", }); - }); + setTimelineState(timelineState); + } + ); } : undefined, }; |