From 8cdc66274596f5fd06a6a59ab9e95e4a16de28c0 Mon Sep 17 00:00:00 2001 From: boojack Date: Fri, 7 Apr 2023 08:53:20 +0800 Subject: [PATCH] chore: update memo visibility display (#1485) --- web/src/components/Memo.tsx | 10 +-- web/src/components/SearchBar.tsx | 12 +--- web/src/components/ShareMemoDialog.tsx | 84 ++++++++++++++------------ web/src/less/memo-editor.less | 4 +- web/src/less/memo.less | 2 +- web/src/less/share-memo-dialog.less | 79 ------------------------ web/src/locales/en.json | 7 +-- web/src/store/module/global.ts | 37 +++++------- 8 files changed, 71 insertions(+), 164 deletions(-) diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index 017a8bc6..19994c5a 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -60,11 +60,6 @@ const Memo: React.FC = (props: Props) => { showEmbedMemoDialog(memo.id); }; - const handleCopyContent = () => { - copy(memo.content); - toast.success(t("message.succeed-copy-content")); - }; - const handleCopyLink = () => { copy(`${window.location.origin}/m/${memo.id}`); toast.success(t("message.succeed-copy-link")); @@ -210,7 +205,7 @@ const Memo: React.FC = (props: Props) => { className={`status-text ${memo.visibility.toLocaleLowerCase()}`} onClick={() => handleMemoVisibilityClick(memo.visibility)} > - {t(`visibility.${memo.visibility}`)} + {t(`memo.visibility.${memo.visibility.toLowerCase()}`)} )} @@ -235,9 +230,6 @@ const Memo: React.FC = (props: Props) => { {t("common.share")} - - {t("memo.copy")} - {t("memo.copy-link")} diff --git a/web/src/components/SearchBar.tsx b/web/src/components/SearchBar.tsx index 8da6ce5f..604df843 100644 --- a/web/src/components/SearchBar.tsx +++ b/web/src/components/SearchBar.tsx @@ -1,15 +1,13 @@ import { useEffect, useState, useRef } from "react"; import { useTranslation } from "react-i18next"; import useDebounce from "@/hooks/useDebounce"; -import { useFilterStore, useDialogStore, useLayoutStore } from "@/store/module"; -import { resolution } from "@/utils/layout"; +import { useFilterStore, useDialogStore } from "@/store/module"; import Icon from "./Icon"; const SearchBar = () => { const { t } = useTranslation(); const filterStore = useFilterStore(); const dialogStore = useDialogStore(); - const layoutStore = useLayoutStore(); const [queryText, setQueryText] = useState(""); const inputRef = useRef(null); @@ -39,14 +37,6 @@ const SearchBar = () => { setQueryText(text === undefined ? "" : text); }, [filterStore.state.text]); - useEffect(() => { - if (layoutStore.state.showHomeSidebar) { - if (window.innerWidth < resolution.sm) { - inputRef.current?.focus(); - } - } - }, [layoutStore.state.showHomeSidebar]); - useDebounce( () => { filterStore.setTextFilter(queryText.length === 0 ? undefined : queryText); diff --git a/web/src/components/ShareMemoDialog.tsx b/web/src/components/ShareMemoDialog.tsx index 54b40064..77498941 100644 --- a/web/src/components/ShareMemoDialog.tsx +++ b/web/src/components/ShareMemoDialog.tsx @@ -23,7 +23,8 @@ interface Props extends DialogProps { interface State { memoAmount: number; - memoVisibility: string; + memoVisibility: Visibility; + showQRCode: boolean; } const ShareMemoDialog: React.FC = (props: Props) => { @@ -37,6 +38,7 @@ const ShareMemoDialog: React.FC = (props: Props) => { const [state, setState] = useState({ memoAmount: 0, memoVisibility: propsMemo.visibility, + showQRCode: true, }); const createLoadingState = useLoading(false); const loadingState = useLoading(); @@ -50,11 +52,8 @@ const ShareMemoDialog: React.FC = (props: Props) => { useEffect(() => { getMemoStats(user.id) .then(({ data: { data } }) => { - setState((state) => { - return { - ...state, - memoAmount: data.length, - }; + setPartialState({ + memoAmount: data.length, }); loadingState.setFinish(); }) @@ -63,6 +62,13 @@ const ShareMemoDialog: React.FC = (props: Props) => { }); }, []); + const setPartialState = (partialState: Partial) => { + setState({ + ...state, + ...partialState, + }); + }; + const handleCloseBtnClick = () => { destroy(); }; @@ -104,8 +110,7 @@ const ShareMemoDialog: React.FC = (props: Props) => { const handleMemoVisibilityOptionChanged = async (value: string) => { const visibilityValue = value as Visibility; - setState({ - ...state, + setPartialState({ memoVisibility: visibilityValue, }); await memoStore.patchMemo({ @@ -116,39 +121,14 @@ const ShareMemoDialog: React.FC = (props: Props) => { return ( <> -
-

{t("common.share")} Memo

+
+

{t("common.share")} Memo

-
-
- {memo.createdAtStr} -
- - -
-
-
- -
-
- {user.nickname || user.username} - - {state.memoAmount} MEMOS / {createdDays} DAYS - -
- -
-
-
+
+