Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for isPasswordProtectd and isPasswordAuthenticated being null before sending cursor updates #47

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions client/src/scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 160,22 @@ export async function sendCursorUpdates(room: Room<RoomState>, interval = 40) {
console.log("Websocket connection open, sending cursor updates");
window.clearInterval(cursorInterval);
cursorInterval = window.setInterval(async () => {
if (room.state.isPasswordProtected && !get(currentUser).isPasswordAuthenticated) return;
try {
if (transport.ws.readyState !== WebSocket.OPEN) {
// if (room.state.isPasswordProtected && !get(currentUser).isPasswordAuthenticated) return;
if (
room.state.isPasswordProtected != null &&
((room.state.isPasswordProtected &&
get(currentUser).isPasswordAuthenticated != null &&
get(currentUser).isPasswordAuthenticated) ||
!room.state.isPasswordProtected)
) {
try {
if (transport.ws.readyState !== WebSocket.OPEN) {
window.clearInterval(cursorInterval);
throw new Error("Websocket connection not open.");
} else room.send("setCursor", get(trackedCursor));
} catch (err) {
window.clearInterval(cursorInterval);
throw new Error("Websocket connection not open.");
} else room.send("setCursor", get(trackedCursor));
} catch (err) {
window.clearInterval(cursorInterval);
}
}
}, interval);
} else {
Expand Down