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 | 9d1d88bacf121699ddf085b799ce191c0d7d3a50 (patch) | |
tree | 229570362ecdcf0d070cab831f5a667a7ea87f7b /FrontEnd/src/app/views | |
parent | f704d13bb67a20d4009b4b990ec2942b50849431 (diff) | |
download | timeline-9d1d88bacf121699ddf085b799ce191c0d7d3a50.tar.gz timeline-9d1d88bacf121699ddf085b799ce191c0d7d3a50.tar.bz2 timeline-9d1d88bacf121699ddf085b799ce191c0d7d3a50.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, }; |