Skip to content

Commit

Permalink
fix: compact mode storage (#4279)
Browse files Browse the repository at this point in the history
fix #4274 now when checkbox is toggled the memo remembers the compact state

Co-authored-by: root <root@DESKTOP-G3MCU14>
  • Loading branch information
X1Vi and root authored Jan 10, 2025
1 parent ac7121c commit 972ebba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/src/components/MemoContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ const MemoContent: React.FC<Props> = (props: Props) => {
SNIPPET: { text: t("memo.show-less"), nextState: "ALL" },
};

useEffect(() => {
sessionStorage.getItem(`${memoName}`) && setShowCompactMode(sessionStorage.getItem(`${memoName}`) as ContentCompactView);
}, []);

return (
<RendererContext.Provider
value={{
Expand Down Expand Up @@ -113,6 +117,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
className="w-auto flex flex-row justify-start items-center cursor-pointer text-sm text-blue-600 dark:text-blue-400 hover:opacity-80"
onClick={() => {
setShowCompactMode(compactStates[showCompactMode].nextState as ContentCompactView);
sessionStorage.setItem(`${memoName}`, compactStates[showCompactMode].nextState);
}}
>
{compactStates[showCompactMode].text}
Expand Down

0 comments on commit 972ebba

Please sign in to comment.