feat: Collaborative revision restore (#2721)

This commit is contained in:
Tom Moor
2021-11-07 08:58:44 -08:00
committed by GitHub
parent 5dd5df6268
commit b2a1e6b309
6 changed files with 57 additions and 17 deletions

View File

@@ -20,9 +20,10 @@ import { homePath } from "utils/routeHelpers";
type Props = {|
...EditorProps,
id: string,
onSynced?: () => void,
|};
function MultiplayerEditor({ ...props }: Props, ref: any) {
function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
const documentId = props.id;
const history = useHistory();
const { t } = useTranslation();
@@ -154,6 +155,12 @@ function MultiplayerEditor({ ...props }: Props, ref: any) {
];
}, [remoteProvider, user, ydoc]);
React.useEffect(() => {
if (isLocalSynced && isRemoteSynced) {
onSynced?.();
}
}, [onSynced, isLocalSynced, isRemoteSynced]);
// Disconnect the realtime connection while idle. `isIdle` also checks for
// page visibility and will immediately disconnect when a tab is hidden.
React.useEffect(() => {