aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-20 15:19:58 +0800
committercrupest <crupest@outlook.com>2021-02-20 15:25:52 +0800
commitd0a318625a30f32e5c0aef24c1882a52de164eb3 (patch)
tree123df54518f6082666af413cd5158e51e8b352fc /FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
parentb1eb0130ed560cb725a313e9743682b2e5f799f7 (diff)
downloadtimeline-d0a318625a30f32e5c0aef24c1882a52de164eb3.tar.gz
timeline-d0a318625a30f32e5c0aef24c1882a52de164eb3.tar.bz2
timeline-d0a318625a30f32e5c0aef24c1882a52de164eb3.zip
fix: Fix reload logic.
Diffstat (limited to 'FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx')
-rw-r--r--FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx61
1 files changed, 20 insertions, 41 deletions
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
index 49cbe791..13b823bf 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePageCardTemplate.tsx
@@ -49,21 +49,6 @@ 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 (
@@ -81,25 +66,22 @@ const TimelinePageCardTemplate: React.FC<TimelineCardTemplateProps> = ({
<div className="text-right mt-2">
<i
className={clsx(
- isHighlight ? "bi-star-fill" : "bi-star",
+ timeline.isHighlight ? "bi-star-fill" : "bi-star",
"icon-button text-yellow mr-3"
)}
onClick={
user?.hasHighlightTimelineAdministrationPermission
? () => {
getHttpHighlightClient()
- [isHighlight ? "delete" : "put"](timeline.name)
- .then(
- () => setOverrideIsHighlight(!isHighlight),
- () => {
- pushAlert({
- message: timeline.isHighlight
- ? "timeline.removeHighlightFail"
- : "timeline.addHighlightFail",
- type: "danger",
- });
- }
- );
+ [timeline.isHighlight ? "delete" : "put"](timeline.name)
+ .then(onReload, () => {
+ pushAlert({
+ message: timeline.isHighlight
+ ? "timeline.removeHighlightFail"
+ : "timeline.addHighlightFail",
+ type: "danger",
+ });
+ });
}
: undefined
}
@@ -107,23 +89,20 @@ const TimelinePageCardTemplate: React.FC<TimelineCardTemplateProps> = ({
{user != null ? (
<i
className={clsx(
- isBookmark ? "bi-bookmark-fill" : "bi-bookmark",
+ timeline.isBookmark ? "bi-bookmark-fill" : "bi-bookmark",
"icon-button text-yellow mr-3"
)}
onClick={() => {
getHttpBookmarkClient()
- [isBookmark ? "delete" : "put"](timeline.name)
- .then(
- () => setOverrideIsBookmark(!isBookmark),
- () => {
- pushAlert({
- message: timeline.isBookmark
- ? "timeline.removeBookmarkFail"
- : "timeline.addBookmarkFail",
- type: "danger",
- });
- }
- );
+ [timeline.isBookmark ? "delete" : "put"](timeline.name)
+ .then(onReload, () => {
+ pushAlert({
+ message: timeline.isBookmark
+ ? "timeline.removeBookmarkFail"
+ : "timeline.addBookmarkFail",
+ type: "danger",
+ });
+ });
}}
/>
) : null}