diff options
Diffstat (limited to 'FrontEnd/src/app/views')
4 files changed, 75 insertions, 40 deletions
diff --git a/FrontEnd/src/app/views/admin/UserAdmin.tsx b/FrontEnd/src/app/views/admin/UserAdmin.tsx index d66abbec..fbdfd5a3 100644 --- a/FrontEnd/src/app/views/admin/UserAdmin.tsx +++ b/FrontEnd/src/app/views/admin/UserAdmin.tsx @@ -62,7 +62,7 @@ const UsernameLabel: React.FC = (props) => { const UserDeleteDialog: React.FC< DialogProps<{ username: string }, unknown> -> = ({ open, close, token, data: { username }, onSuccess }) => { +> = ({ open, close, data: { username }, onSuccess }) => { return ( <OperationDialog open={open} @@ -74,7 +74,7 @@ const UserDeleteDialog: React.FC< 0<UsernameLabel>{username}</UsernameLabel>2 </Trans> )} - onProcess={() => getHttpUserClient().delete(username, token)} + onProcess={() => getHttpUserClient().delete(username)} onSuccessAndClose={onSuccess} /> ); @@ -87,7 +87,7 @@ const UserModifyDialog: React.FC< }, HttpUser > -> = ({ open, close, token, data: { oldUser }, onSuccess }) => { +> = ({ open, close, data: { oldUser }, onSuccess }) => { return ( <OperationDialog open={open} @@ -115,15 +115,11 @@ const UserModifyDialog: React.FC< ] as const } onProcess={([username, password, nickname]) => - getHttpUserClient().patch( - oldUser.username, - { - username: username !== oldUser.username ? username : undefined, - password: password !== "" ? password : undefined, - nickname: nickname !== oldUser.nickname ? nickname : undefined, - }, - token - ) + getHttpUserClient().patch(oldUser.username, { + username: username !== oldUser.username ? username : undefined, + password: password !== "" ? password : undefined, + nickname: nickname !== oldUser.nickname ? nickname : undefined, + }) } onSuccessAndClose={onSuccess} /> @@ -138,7 +134,7 @@ const UserPermissionModifyDialog: React.FC< }, UserPermission[] > -> = ({ open, close, token, data: { username, permissions }, onSuccess }) => { +> = ({ open, close, data: { username, permissions }, onSuccess }) => { const oldPermissionBoolList: boolean[] = kUserPermissionList.map( (permission) => permissions.includes(permission) ); @@ -168,16 +164,11 @@ const UserPermissionModifyDialog: React.FC< const permission = kUserPermissionList[index]; if (oldValue === newValue) continue; if (newValue) { - await getHttpUserClient().putUserPermission( - username, - permission, - token - ); + await getHttpUserClient().putUserPermission(username, permission); } else { await getHttpUserClient().deleteUserPermission( username, - permission, - token + permission ); } } diff --git a/FrontEnd/src/app/views/home/BoardWithUser.tsx b/FrontEnd/src/app/views/home/BoardWithUser.tsx index 8afe440b..ba22916c 100644 --- a/FrontEnd/src/app/views/home/BoardWithUser.tsx +++ b/FrontEnd/src/app/views/home/BoardWithUser.tsx @@ -20,11 +20,11 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { <Col xs="12" md="6"> <TimelineBoard title={t("home.bookmarkTimeline")} - load={() => getHttpBookmarkClient().list(user.token)} + load={() => getHttpBookmarkClient().list()} editHandler={{ onDelete: (timeline) => { return getHttpBookmarkClient() - .delete(timeline, user.token) + .delete(timeline) .catch((e) => { pushAlert({ message: { @@ -39,8 +39,7 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { onMove: (timeline, index, offset) => { return getHttpBookmarkClient() .move( - { timeline, newPosition: index + offset + 1 }, // +1 because backend contract: index starts at 1 - user.token + { timeline, newPosition: index + offset + 1 } // +1 because backend contract: index starts at 1 ) .catch((e) => { pushAlert({ @@ -75,7 +74,7 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { ? { onDelete: (timeline) => { return getHttpHighlightClient() - .delete(timeline, user.token) + .delete(timeline) .catch((e) => { pushAlert({ message: { @@ -90,8 +89,7 @@ const BoardWithUser: React.FC<{ user: AuthUser }> = ({ user }) => { onMove: (timeline, index, offset) => { return getHttpHighlightClient() .move( - { timeline, newPosition: index + offset + 1 }, // +1 because backend contract: index starts at 1 - user.token + { timeline, newPosition: index + offset + 1 } // +1 because backend contract: index starts at 1 ) .catch((e) => { pushAlert({ diff --git a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx index ece1942f..b2b349bc 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelineCardTemplate.tsx @@ -56,13 +56,19 @@ function TimelineCardTemplate({ <div className="text-right mt-2"> {onHighlight != null ? ( <i - className="bi-star icon-button text-yellow mr-3" + className={clsx( + timeline.isHighlight ? "bi-star-fill" : "bi-star", + "icon-button text-yellow mr-3" + )} onClick={onHighlight} /> ) : null} {onBookmark != null ? ( <i - className="bi-bookmark icon-button text-yellow mr-3" + className={clsx( + timeline.isBookmark ? "bi-bookmark-fill" : "bi-bookmark", + "icon-button text-yellow mr-3" + )} onClick={onBookmark} /> ) : null} diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx index 7f5c8206..caced3b7 100644 --- a/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx +++ b/FrontEnd/src/app/views/timeline-common/TimelinePageTemplate.tsx @@ -45,7 +45,7 @@ export default function TimelinePageTemplate<TManageItem>( null ); - const timelineState = useTimelineInfo(name); + const [timelineState, setTimelineState] = useTimelineInfo(name); const postListState = usePostList(name); const onPost: TimelinePostSendCallback = React.useCallback( @@ -121,24 +121,64 @@ export default function TimelinePageTemplate<TManageItem>( onBookmark: user != null ? () => { - void getHttpBookmarkClient() - .put(name, user.token) - .then(() => { - pushAlert({ - message: { - type: "i18n", - key: "timeline.addBookmarkSuccess", + if (timeline.isBookmark) { + setTimelineState({ + ...timelineState, + timeline: { + ...timeline, + isBookmark: false, + }, + }); + void getHttpBookmarkClient() + .delete(name) + .then( + () => { + void timelineService.syncTimeline(name); }, - type: "success", - }); + () => { + pushAlert({ + message: { + type: "i18n", + key: "timeline.removeBookmarkFail", + }, + type: "danger", + }); + setTimelineState(timelineState); + } + ); + } else { + setTimelineState({ + ...timelineState, + timeline: { + ...timeline, + isBookmark: true, + }, }); + void getHttpBookmarkClient() + .put(name) + .then( + () => { + void timelineService.syncTimeline(name); + }, + () => { + pushAlert({ + message: { + type: "i18n", + key: "timeline.addBookmarkFail", + }, + type: "danger", + }); + setTimelineState(timelineState); + } + ); + } } : undefined, onHighlight: user != null && user.hasHighlightTimelineAdministrationPermission ? () => { void getHttpHighlightClient() - .put(name, user.token) + .put(name) .then(() => { pushAlert({ message: { |