fix: Awareness state not available if server dies and restarts

This commit is contained in:
Tom Moor committed 2020-10-24 19:46:08 -07:00
1 parent a28dfa77ee
commit 700db463fc
3 files changed
+10 -8

No files matched your search

+7 -3
View File
@@ -19,9 +19,13 @@ export default class MultiplayerExtension extends Extension {
const { user, provider, doc } = this.options;
const type = doc.get("prosemirror", Y.XmlFragment);
provider.awareness.setLocalStateField("user", {
color: user.color,
name: user.name,
provider.on("status", ({ status }) => {
if (status === "connected") {
provider.awareness.setLocalStateField("user", {
color: user.color,
name: user.name,
});
}
});
const permanentUserData = new Y.PermanentUserData(doc);
+2
View File
@@ -293,6 +293,8 @@ export class WebsocketProvider extends Observable {
}
console.log("user.join");
this.awareness.setLocalState({});
this.emit("status", [
{
status: "connected",
@@ -33,11 +33,7 @@ export default function SocketPresence(props: Props) {
context.on("authenticated", () => {
console.log("authenticated");
// wait just a hair to join the presence room, this is mainly for a
// development race condition where the join event could be emitted before
// the listener is added on the server
setTimeout(emitJoin, 100);
emitJoin();
});
if (context.authenticated) {