From 8c312e647d74c6852078d93e2d8236b679cbb39e Mon Sep 17 00:00:00 2001 From: boojack Date: Thu, 24 Aug 2023 22:00:48 +0800 Subject: [PATCH] chore: remove auto collapse setting (#2169) --- web/src/components/DailyMemo.tsx | 2 +- web/src/components/Memo.tsx | 4 +- web/src/components/MemoContent.tsx | 56 +------------------ .../Settings/PreferencesSection.tsx | 9 --- web/src/components/ShareMemoDialog.tsx | 2 +- web/src/pages/MemoDetail.tsx | 2 +- web/src/store/module/user.ts | 1 - web/src/types/modules/setting.d.ts | 1 - 8 files changed, 7 insertions(+), 70 deletions(-) diff --git a/web/src/components/DailyMemo.tsx b/web/src/components/DailyMemo.tsx index 66e3286c..42170c82 100644 --- a/web/src/components/DailyMemo.tsx +++ b/web/src/components/DailyMemo.tsx @@ -17,7 +17,7 @@ const DailyMemo: React.FC = (props: Props) => { {displayTimeStr}
- +
diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx index 8a0e9c2c..efda89d9 100644 --- a/web/src/components/Memo.tsx +++ b/web/src/components/Memo.tsx @@ -24,14 +24,13 @@ import "@/less/memo.less"; interface Props { memo: Memo; showCreator?: boolean; - showFull?: boolean; showVisibility?: boolean; showRelatedMemos?: boolean; lazyRendering?: boolean; } const Memo: React.FC = (props: Props) => { - const { memo, showCreator, showFull, showRelatedMemos, lazyRendering } = props; + const { memo, showCreator, showRelatedMemos, lazyRendering } = props; const { i18n } = useTranslation(); const t = useTranslate(); const filterStore = useFilterStore(); @@ -303,7 +302,6 @@ const Memo: React.FC = (props: Props) => { diff --git a/web/src/components/MemoContent.tsx b/web/src/components/MemoContent.tsx index 79d3f45f..4dc2f2cc 100644 --- a/web/src/components/MemoContent.tsx +++ b/web/src/components/MemoContent.tsx @@ -1,51 +1,17 @@ -import { useEffect, useRef, useState } from "react"; +import { useRef } from "react"; import { marked } from "@/labs/marked"; -import { useUserStore } from "@/store/module"; -import { useTranslate } from "@/utils/i18n"; -import Icon from "./Icon"; import "@/less/memo-content.less"; -const MAX_EXPAND_HEIGHT = 384; - interface Props { content: string; className?: string; - showFull?: boolean; onMemoContentClick?: (e: React.MouseEvent) => void; onMemoContentDoubleClick?: (e: React.MouseEvent) => void; } -type ExpandButtonStatus = -1 | 0 | 1; - -interface State { - expandButtonStatus: ExpandButtonStatus; -} - const MemoContent: React.FC = (props: Props) => { - const { className, content, showFull, onMemoContentClick, onMemoContentDoubleClick } = props; - const t = useTranslate(); - const userStore = useUserStore(); - const [state, setState] = useState({ - expandButtonStatus: -1, - }); + const { className, content, onMemoContentClick, onMemoContentDoubleClick } = props; const memoContentContainerRef = useRef(null); - const isVisitorMode = userStore.isVisitorMode(); - const autoCollapse: boolean = !showFull && (isVisitorMode ? true : (userStore.state.user as User).localSetting.enableAutoCollapse); - - useEffect(() => { - if (!autoCollapse) { - return; - } - - if (memoContentContainerRef.current) { - const height = memoContentContainerRef.current.scrollHeight; - if (height > MAX_EXPAND_HEIGHT) { - setState({ - expandButtonStatus: 0, - }); - } - } - }, [autoCollapse]); const handleMemoContentClick = async (e: React.MouseEvent) => { if (onMemoContentClick) { @@ -59,32 +25,16 @@ const MemoContent: React.FC = (props: Props) => { } }; - const handleExpandBtnClick = () => { - const expandButtonStatus = Boolean(!state.expandButtonStatus); - setState({ - expandButtonStatus: Number(expandButtonStatus) as ExpandButtonStatus, - }); - }; - return (
{marked(content)}
- {autoCollapse && state.expandButtonStatus !== -1 && ( -
-
- - {state.expandButtonStatus === 0 ? t("common.expand") : t("common.fold")} - - -
- )}
); }; diff --git a/web/src/components/Settings/PreferencesSection.tsx b/web/src/components/Settings/PreferencesSection.tsx index 03294e73..d1e0db1b 100644 --- a/web/src/components/Settings/PreferencesSection.tsx +++ b/web/src/components/Settings/PreferencesSection.tsx @@ -47,10 +47,6 @@ const PreferencesSection = () => { userStore.upsertLocalSetting({ ...localSetting, dailyReviewTimeOffset: value }); }; - const handleAutoCollapseChanged = (event: React.ChangeEvent) => { - userStore.upsertLocalSetting({ ...localSetting, enableAutoCollapse: event.target.checked }); - }; - const handleSaveTelegramUserId = async () => { try { await userStore.upsertUserSetting("telegram-user-id", telegramUserId); @@ -130,11 +126,6 @@ const PreferencesSection = () => { - -
diff --git a/web/src/components/ShareMemoDialog.tsx b/web/src/components/ShareMemoDialog.tsx index e46d20b2..b24f10f4 100644 --- a/web/src/components/ShareMemoDialog.tsx +++ b/web/src/components/ShareMemoDialog.tsx @@ -174,7 +174,7 @@ const ShareMemoDialog: React.FC = (props: Props) => { > {memo.displayTsStr}
- +
diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsx index 559bbbc5..9ccd32b1 100644 --- a/web/src/pages/MemoDetail.tsx +++ b/web/src/pages/MemoDetail.tsx @@ -45,7 +45,7 @@ const MemoDetail = () => { (memo ? ( <>
- +