fix: fix the moment to delete provider

This commit is contained in:
fantasticit 2022-05-02 17:29:22 +08:00
parent 344cc5b05c
commit 5540c0dfab
2 changed files with 9 additions and 16 deletions

View File

@ -65,6 +65,9 @@ export const Editor: React.FC<IProps> = ({ user: currentUser, documentId, author
onSynced() { onSynced() {
toggleLoading(false); toggleLoading(false);
}, },
onStatus({ status }) {
setStatus(status);
},
}, },
}); });
}, [documentId, currentUser, toggleLoading]); }, [documentId, currentUser, toggleLoading]);
@ -85,22 +88,15 @@ export const Editor: React.FC<IProps> = ({ user: currentUser, documentId, author
// //
} }
}, 50), }, 50),
onDestroy() {
destoryProvider(provider, 'EDITOR');
},
}, },
[authority, provider] [authority, provider]
); );
const [mentionUsersSettingVisible, toggleMentionUsersSettingVisible] = useToggle(false); const [mentionUsersSettingVisible, toggleMentionUsersSettingVisible] = useToggle(false);
const [mentionUsers, setMentionUsers] = useState([]); const [mentionUsers, setMentionUsers] = useState([]);
useEffect(() => {
provider.on('status', async ({ status }) => {
setStatus(status);
});
return () => {
destoryProvider(provider, 'EDITOR');
};
}, [documentId, provider, authority]);
useEffect(() => { useEffect(() => {
if (!authority || !authority.editable) return; if (!authority || !authority.editable) return;

View File

@ -64,13 +64,10 @@ export const Editor: React.FC<IProps> = ({ user, documentId, document, children
// @ts-ignore // @ts-ignore
taskItemClickable: true, taskItemClickable: true,
}, },
}); onDestroy() {
useEffect(() => {
return () => {
destoryProvider(provider, 'READER'); destoryProvider(provider, 'READER');
}; },
}, [provider]); });
return ( return (
<DataRender <DataRender