Skip to content
Snippets Groups Projects
Commit 3af54c4e authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) Fixed global pathElems map (now per room connection)

parent 52f2594e
No related branches found
No related tags found
1 merge request!28Rooms and frontend
Pipeline #101755 passed
......@@ -20,9 +20,7 @@ const STROKECOLOUR = "blue"
const STROKERADIUS = 2
const ERASERRADIUS = STROKERADIUS * 2
const pathElems = new Map()
const addOrUpdatePathElem = (id, points) => {
const addOrUpdatePathElem = (pathElems, id, points) => {
let pathElem = pathElems.get(id)
if (pathElem == null) {
......@@ -129,6 +127,8 @@ function handleRoomConnectionEstablished(room) {
let userInput = false
let currentTool = tools.PEN
let pathElems = new Map()
let currentPathID = null
HTML.userIDElem.value = room.ownID || ""
......@@ -159,7 +159,7 @@ function handleRoomConnectionEstablished(room) {
})
room.addEventListener("addOrUpdatePath", ({ detail: { id, points } }) => {
addOrUpdatePathElem(id, points)
addOrUpdatePathElem(pathElems, id, points)
})
const canvasOnMouseDown = (e) => {
......@@ -265,6 +265,9 @@ function handleRoomConnectionEstablished(room) {
HTML.roomConnectButton.removeEventListener("click", handleRoomConnectClick)
const roomConnectButtonOnClick = () => {
const selectedRoomID = HTML.roomIDElem.value
if (!selectedRoomID || selectedRoomID === room.name) return
HTML.canvas.removeEventListener("mousedown", canvasOnMouseDown)
HTML.canvas.removeEventListener("mouseleave", canvasOnMouseLeave)
HTML.canvas.removeEventListener("mouseenter", canvasOnMouseEnter)
......@@ -273,15 +276,17 @@ function handleRoomConnectionEstablished(room) {
HTML.peerButton.removeEventListener("click", peerButtonOnClick)
HTML.penButton.removeEventListener("click", penButtonOnClick)
HTML.eraserButton.removeEventListener("click", eraserButtonOnClick)
HTML.roomConnectButton.removeEventListener(
"click",
roomConnectButtonOnClick,
)
room.disconnect()
room = undefined
handleRoomConnectClick()
}
HTML.roomConnectButton.addEventListener("click", roomConnectButtonOnClick, {
once: true,
})
HTML.roomConnectButton.addEventListener("click", roomConnectButtonOnClick)
}
function handleRoomConnectionError(err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment