aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-15 01:35:41 +0800
committercrupest <crupest@outlook.com>2021-02-15 01:35:41 +0800
commitc035e16298011c366fe42f40a1709c5509a3114c (patch)
tree906f476117a9e182b612f658726a08aac779a7bb /FrontEnd/src
parentfeaa3296288e3e4b872f60de002d7f9e2a690bc6 (diff)
downloadtimeline-c035e16298011c366fe42f40a1709c5509a3114c.tar.gz
timeline-c035e16298011c366fe42f40a1709c5509a3114c.tar.bz2
timeline-c035e16298011c366fe42f40a1709c5509a3114c.zip
fix: Timeline highlight and bookmark buttom no reaction.
Diffstat (limited to 'FrontEnd/src')
-rw-r--r--FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx64
-rw-r--r--FrontEnd/src/app/views/timeline-common/timeline-common.sass8
2 files changed, 42 insertions, 30 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
index 921f1390..49cbe791 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
@@ -49,6 +49,21 @@ const TimelinePageCardTemplate: React.FC<TimelineCardTemplateProps> = ({
}) => {
const { t } = useTranslation();
+ const [overrideIsHighlight, setOverrideIsHighlight] = React.useState<
+ boolean | null
+ >(null);
+ const [overrideIsBookmark, setOverrideIsBookmark] = React.useState<
+ boolean | null
+ >(null);
+
+ const isHighlight = overrideIsHighlight ?? timeline.isHighlight;
+ const isBookmark = overrideIsBookmark ?? timeline.isBookmark;
+
+ React.useEffect(() => {
+ setOverrideIsHighlight(null);
+ setOverrideIsBookmark(null);
+ }, [timeline]);
+
const user = useUser();
return (
@@ -66,23 +81,25 @@ const TimelinePageCardTemplate: React.FC<TimelineCardTemplateProps> = ({
<div className="text-right mt-2">
<i
className={clsx(
- timeline.isHighlight ? "bi-star-fill" : "bi-star",
+ isHighlight ? "bi-star-fill" : "bi-star",
"icon-button text-yellow mr-3"
)}
onClick={
- user != null &&
- user.hasHighlightTimelineAdministrationPermission
+ user?.hasHighlightTimelineAdministrationPermission
? () => {
getHttpHighlightClient()
- [timeline.isHighlight ? "delete" : "put"](timeline.name)
- .catch(() => {
- pushAlert({
- message: timeline.isHighlight
- ? "timeline.removeHighlightFail"
- : "timeline.addHighlightFail",
- type: "danger",
- });
- });
+ [isHighlight ? "delete" : "put"](timeline.name)
+ .then(
+ () => setOverrideIsHighlight(!isHighlight),
+ () => {
+ pushAlert({
+ message: timeline.isHighlight
+ ? "timeline.removeHighlightFail"
+ : "timeline.addHighlightFail",
+ type: "danger",
+ });
+ }
+ );
}
: undefined
}
@@ -90,20 +107,23 @@ const TimelinePageCardTemplate: React.FC<TimelineCardTemplateProps> = ({
{user != null ? (
<i
className={clsx(
- timeline.isBookmark ? "bi-bookmark-fill" : "bi-bookmark",
+ isBookmark ? "bi-bookmark-fill" : "bi-bookmark",
"icon-button text-yellow mr-3"
)}
onClick={() => {
getHttpBookmarkClient()
- [timeline.isBookmark ? "delete" : "put"](timeline.name)
- .catch(() => {
- pushAlert({
- message: timeline.isBookmark
- ? "timeline.removeBookmarkFail"
- : "timeline.addBookmarkFail",
- type: "danger",
- });
- });
+ [isBookmark ? "delete" : "put"](timeline.name)
+ .then(
+ () => setOverrideIsBookmark(!isBookmark),
+ () => {
+ pushAlert({
+ message: timeline.isBookmark
+ ? "timeline.removeBookmarkFail"
+ : "timeline.addBookmarkFail",
+ type: "danger",
+ });
+ }
+ );
}}
/>
) : null}
diff --git a/FrontEnd/src/app/views/timeline-common/timeline-common.sass b/FrontEnd/src/app/views/timeline-common/timeline-common.sass
index 1a7bfc3b..31404d8c 100644
--- a/FrontEnd/src/app/views/timeline-common/timeline-common.sass
+++ b/FrontEnd/src/app/views/timeline-common/timeline-common.sass
@@ -170,11 +170,3 @@ $timeline-line-color-current: #36c2e6
top: 56px
right: 0
margin: 0.5em
-
-.timeline-container
- display: flex
- justify-content: center
-
- .timeline
- max-width: 80em
- flex-grow: 1