From 0ce2f0d0aec2ced4fcb294b61ff6aa0a906a1bb6 Mon Sep 17 00:00:00 2001 From: danshuitaihejie <474182370@qq.com> Date: Sun, 19 May 2024 19:15:56 +0800 Subject: [PATCH 1/2] feat: show saved state to user --- src/components/MainHeader.jsx | 2 + src/components/SaveStatusButton.jsx | 79 +++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/components/SaveStatusButton.jsx diff --git a/src/components/MainHeader.jsx b/src/components/MainHeader.jsx index 0c187b69..6c6aaf20 100644 --- a/src/components/MainHeader.jsx +++ b/src/components/MainHeader.jsx @@ -8,6 +8,7 @@ import { SharePanel } from './SharePanel'; import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; import userService from '../services/user_service'; import mixpanel from '../services/mixpanel'; +import { SaveStatusButton } from './SaveStatusButton'; export function MainHeader(props) { const [isEditing, setEditing] = useState(false); @@ -188,6 +189,7 @@ export function MainHeader(props) { {props.externalLibCount} + {!window.user ? ( { + setShowTip(true); + }; + + const handleMouseLeave = () => { + setShowTip(false); + }; + let showSavedTimeout = null; + useEffect(() => { + if (isSaving == false) { + setShowSaved(true); + if (showSavedTimeout) clearTimeout(showSavedTimeout); + showSavedTimeout = setTimeout(() => { + setShowSaved(false); + }, 1500); + } + }, [isSaving]); + + return ( + + + + + + + + + + {isShowSaved && ( + + Saved to cloud + + )} + + {isShowTip && ( + + + + + + + + + + All changes auto-save to cloud + + + )} + + ); +} + +export { SaveStatusButton }; From 52aef9398a6f32d39a0ca8f96322c1837bbda30b Mon Sep 17 00:00:00 2001 From: danshuitaihejie <474182370@qq.com> Date: Sat, 8 Jun 2024 17:42:27 +0800 Subject: [PATCH 2/2] fix: avoid title jitter when saving --- src/components/SaveStatusButton.jsx | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/components/SaveStatusButton.jsx b/src/components/SaveStatusButton.jsx index 0e81dd47..17537595 100644 --- a/src/components/SaveStatusButton.jsx +++ b/src/components/SaveStatusButton.jsx @@ -21,13 +21,13 @@ function SaveStatusButton({ isSaving }) { }, [isSaving]); return ( - + - + @@ -41,6 +41,32 @@ function SaveStatusButton({ isSaving }) { /> + {isShowTip && ( + + + + + + + + + + + All changes auto-save to cloud + + + + )} {isShowSaved && ( @@ -48,30 +74,6 @@ function SaveStatusButton({ isSaving }) { )} - {isShowTip && ( - - - - - - - - - - All changes auto-save to cloud - - - )} ); }
Saved to cloud
All changes auto-save to cloud
+ All changes auto-save to cloud +