diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index ec990dee..64fecbda 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -3,6 +3,7 @@ import relativeTime from "dayjs/plugin/relativeTime"; import { indexOf } from "lodash-es"; import { memo, useEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; +import { useNavigate } from "react-router-dom"; import "dayjs/locale/zh"; import { UNKNOWN_ID } from "../helpers/consts"; import { DONE_BLOCK_REG, TODO_BLOCK_REG } from "../helpers/marked"; @@ -32,6 +33,7 @@ export const getFormatedMemoCreatedAtStr = (createdTs: number, locale = "en"): s const Memo: React.FC = (props: Props) => { const memo = props.memo; const { t, i18n } = useTranslation(); + const navigate = useNavigate(); const [createdAtStr, setCreatedAtStr] = useState(getFormatedMemoCreatedAtStr(memo.createdTs, i18n.language)); const memoContainerRef = useRef(null); const isVisitorMode = userService.isVisitorMode(); @@ -50,9 +52,17 @@ const Memo: React.FC = (props: Props) => { }, [i18n.language]); const handleShowMemoStoryDialog = () => { + if (isVisitorMode) { + return; + } + showMemoCardDialog(memo); }; + const handleViewMemoDetailPage = () => { + navigate(`/m/${memo.id}`); + }; + const handleTogglePinMemoBtnClick = async () => { try { if (memo.pinned) { @@ -165,44 +175,48 @@ const Memo: React.FC = (props: Props) => { return (
-
- {createdAtStr} +
+ + {createdAtStr} + {memo.visibility !== "PRIVATE" && !isVisitorMode && ( {memo.visibility} )}
-
- - - -
-
-
-
- - {memo.pinned ? t("common.unpin") : t("common.pin")} -
-
- - {t("common.edit")} -
-
- - {t("common.share")} + {!isVisitorMode && ( +
+ + + +
+
+
+
+ + {memo.pinned ? t("common.unpin") : t("common.pin")} +
+
+ + {t("common.edit")} +
+
+ + {t("common.share")} +
+ + {t("common.mark")} + + + {t("memo.view-detail")} + + + {t("common.archive")} +
- - {t("common.mark")} - - - {t("memo.view-story")} - - - {t("common.archive")} -
-
+ )}
= (props: Props) => { }); const [linkMemos, setLinkMemos] = useState([]); const [linkedMemos, setLinkedMemos] = useState([]); + const isVisitorMode = userService.isVisitorMode(); const visibilitySelectorItems = VISIBILITY_SELECTOR_ITEMS.map((item) => { return { value: item.value, @@ -83,6 +84,10 @@ const MemoCardDialog: React.FC = (props: Props) => { }, [memos, memo.id]); const handleMemoCreatedAtClick = () => { + if (isVisitorMode) { + return; + } + showChangeMemoCreatedTsDialog(memo.id); }; @@ -140,7 +145,7 @@ const MemoCardDialog: React.FC = (props: Props) => { return ( <> - {!userService.isVisitorMode() && ( + {!isVisitorMode && (
@@ -159,7 +164,7 @@ const MemoCardDialog: React.FC = (props: Props) => { {utils.getDateTimeString(memo.createdTs)}

- {!userService.isVisitorMode() && ( + {!isVisitorMode && ( <>