Не подтверждена Коммит b8612f30 создал по автору JimmFly's avatar JimmFly
Просмотр файлов

refactor(core): replace the loading state written in useState with useDebouncedValue (#6925)

close TOV-856

refactor(core): replace the loading state written in useState with useDebouncedState

fix(core): cloudSvg obscures toggle button
владелец c7ddd679
......@@ -73,4 +73,5 @@ export const cloudSvgContainer = style({
position: 'absolute',
bottom: '0',
right: '0',
pointerEvents: 'none',
});
......@@ -7,15 +7,9 @@ import type { DocMeta } from '@blocksuite/store';
import type { CommandCategory } from '@toeverything/infra';
import clsx from 'clsx';
import { Command } from 'cmdk';
import { useDebouncedValue } from 'foxact/use-debounced-value';
import { useAtom } from 'jotai';
import {
Suspense,
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from 'react';
import { Suspense, useLayoutEffect, useMemo, useRef, useState } from 'react';
import {
cmdkQueryAtom,
......@@ -171,7 +165,7 @@ export const CMDKContainer = ({
const isInEditor = pageMeta !== undefined;
const [opening, setOpening] = useState(open);
const { syncing, progress } = useDocEngineStatus();
const [showLoading, setShowLoading] = useState(false);
const showLoading = useDebouncedValue(syncing, 500);
const inputRef = useRef<HTMLInputElement>(null);
......@@ -192,24 +186,6 @@ export const CMDKContainer = ({
return;
}, [open]);
useEffect(() => {
let timeoutId: NodeJS.Timeout | null = null;
if (syncing && !showLoading) {
timeoutId = setTimeout(() => {
setShowLoading(true);
}, 500);
} else if (!syncing && showLoading) {
setShowLoading(false);
}
return () => {
if (timeoutId) {
clearTimeout(timeoutId);
}
};
}, [syncing, showLoading]);
return (
<Command
{...rest}
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать