mirror of https://github.com/fantasticit/think.git
tiptap: add debounce in onAwarenessUpdate
This commit is contained in:
parent
0b77a58d86
commit
1754841fa1
|
@ -5,6 +5,7 @@ import { HocuspocusProvider } from '@hocuspocus/provider';
|
||||||
import { useToggle } from 'hooks/use-toggle';
|
import { useToggle } from 'hooks/use-toggle';
|
||||||
import { SecureDocumentIllustration } from 'illustrations/secure-document';
|
import { SecureDocumentIllustration } from 'illustrations/secure-document';
|
||||||
import { DataRender } from 'components/data-render';
|
import { DataRender } from 'components/data-render';
|
||||||
|
import { debounce } from 'helpers/debounce';
|
||||||
import { Editor } from '../../react';
|
import { Editor } from '../../react';
|
||||||
import { ICollaborationEditorProps, ProviderStatus } from './type';
|
import { ICollaborationEditorProps, ProviderStatus } from './type';
|
||||||
import { EditorInstance } from './editor';
|
import { EditorInstance } from './editor';
|
||||||
|
@ -43,10 +44,10 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
|
||||||
docType: type,
|
docType: type,
|
||||||
},
|
},
|
||||||
maxAttempts: 1,
|
maxAttempts: 1,
|
||||||
onAwarenessUpdate({ states }) {
|
onAwarenessUpdate: debounce(({ states }) => {
|
||||||
const users = states.map((state) => ({ clientId: state.clientId, user: state.user }));
|
const users = states.map((state) => ({ clientId: state.clientId, user: state.user }));
|
||||||
onAwarenessUpdate && onAwarenessUpdate(users);
|
onAwarenessUpdate && onAwarenessUpdate(users);
|
||||||
},
|
}, 200),
|
||||||
onAuthenticationFailed() {
|
onAuthenticationFailed() {
|
||||||
toggleLoading(false);
|
toggleLoading(false);
|
||||||
setError(new Error('鉴权失败!暂时无法提供服务'));
|
setError(new Error('鉴权失败!暂时无法提供服务'));
|
||||||
|
|
Loading…
Reference in New Issue