Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): page mode switch sometimes not working (#5306)

Peng Xiaofc56a53acdc9
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/switch-items.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/switch-items.tsx
index 7d738acce1..cb9f4b20f6 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/switch-items.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-mode-switch/switch-items.tsx
@@ -45,21 +45,30 @@ const HoverAnimateController = ({
);
};
+const pageLottieOptions = {
+ loop: false,
+ autoplay: false,
+ animationData: pageHover,
+ rendererSettings: {
+ preserveAspectRatio: 'xMidYMid slice',
+ },
+};
+
+const edgelessLottieOptions = {
+ loop: false,
+ autoplay: false,
+ animationData: edgelessHover,
+ rendererSettings: {
+ preserveAspectRatio: 'xMidYMid slice',
+ },
+};
+
export const PageSwitchItem = (
props: Omit<HoverAnimateControllerProps, 'children'>
) => {
return (
<HoverAnimateController {...props}>
- <InternalLottie
- options={{
- loop: false,
- autoplay: false,
- animationData: pageHover,
- rendererSettings: {
- preserveAspectRatio: 'xMidYMid slice',
- },
- }}
- />
+ <InternalLottie options={pageLottieOptions} />
</HoverAnimateController>
);
};
@@ -69,16 +78,7 @@ export const EdgelessSwitchItem = (
) => {
return (
<HoverAnimateController {...props}>
- <InternalLottie
- options={{
- loop: false,
- autoplay: false,
- animationData: edgelessHover,
- rendererSettings: {
- preserveAspectRatio: 'xMidYMid slice',
- },
- }}
- />
+ <InternalLottie options={edgelessLottieOptions} />
</HoverAnimateController>
);
};
diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
index 1911cedb26..b955b829f5 100644
--- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
+++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
@@ -14,6 +14,7 @@ import { useWorkspaceStatus } from '@toeverything/hooks/use-workspace-status';
import { appSettingAtom, currentPageIdAtom } from '@toeverything/infra/atom';
import { useAtomValue, useSetAtom } from 'jotai';
import {
+ memo,
type ReactElement,
type ReactNode,
useCallback,
@@ -101,7 +102,7 @@ const DetailPageLayout = ({
);
};
-const DetailPageImpl = ({ page }: { page: Page }) => {
+const DetailPageImpl = memo(function DetailPageImpl({ page }: { page: Page }) {
const currentPageId = page.id;
const { openPage, jumpToSubPath } = useNavigateHelper();
const currentWorkspace = useAtomValue(waitForCurrentWorkspaceAtom);
@@ -200,7 +201,7 @@ const DetailPageImpl = ({ page }: { page: Page }) => {
<GlobalPageHistoryModal />
</>
);
-};
+});
const useForceUpdate = () => {
const [, setCount] = useState(0);