mirror of
https://github.com/outline/outline.git
synced 2026-11-26 23:50:14 +03:00
race
This commit is contained in:
1 parent
0776b78e25
commit
d8bc6515dd
2 files changed
+10
-2
No files matched your search
@@ -22,15 +22,22 @@ export default function SocketPresence(props: Props) {
|
||||
// );
|
||||
|
||||
React.useEffect(() => {
|
||||
console.log("useEffect", context);
|
||||
if (!context) return;
|
||||
|
||||
const emitJoin = () => {
|
||||
if (!context) return;
|
||||
console.log("JOIN");
|
||||
context.emit("join", { documentId: props.documentId });
|
||||
};
|
||||
|
||||
context.on("authenticated", () => {
|
||||
emitJoin();
|
||||
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);
|
||||
});
|
||||
|
||||
if (context.authenticated) {
|
||||
|
||||
+2
-1
@@ -112,7 +112,7 @@ SocketAuth(io, {
|
||||
|
||||
// allow the client to request to join rooms
|
||||
socket.on("join", async (event) => {
|
||||
log("join", JSON.stringify(event));
|
||||
log("join", event.documentId, socket.id);
|
||||
// user is joining a collection channel, because their permissions have
|
||||
// changed, granting them access.
|
||||
if (event.collectionId) {
|
||||
@@ -139,6 +139,7 @@ SocketAuth(io, {
|
||||
// new logic for multiplayer editing completely changes "presence"
|
||||
// detection and propagation, so split at a high-level here.
|
||||
if (team.multiplayerEditor) {
|
||||
log("joined multiplayer", socket.id);
|
||||
socket.join(room, () => {
|
||||
socket.emit("user.join", {
|
||||
userId: user.id,
|
||||
|
||||
Reference in new issue
Block a user