fix some eqeqeq and add store to window for debugging

This commit is contained in:
HF 2023-03-18 02:21:03 +01:00
parent e85073733c
commit 063813cb41
4 changed files with 12 additions and 8 deletions

View File

@ -52,6 +52,10 @@ persistStore(store, {}, () => {
store.dispatch(fetchMe());
socketClient.initialize(store, pixelTransferController, getRenderer);
// for debugging
window.ppStore = store;
window.ppRender = getRenderer;
});
(function load() {

View File

@ -160,8 +160,7 @@ export default async function drawByOffsets(
}
/* dont rank antarctica */
// eslint-disable-next-line eqeqeq
if (canvasId == 0 && y > 14450) {
if (canvasId === 0 && y > 14450) {
ranked = false;
}
}

View File

@ -363,8 +363,7 @@ class SocketServer {
broadcastPixelBuffer(canvasId, chunkid, data) {
if (this.CHUNK_CLIENTS.has(chunkid)) {
const clients = this.CHUNK_CLIENTS.get(chunkid)
// eslint-disable-next-line eqeqeq
.filter((ws) => ws.canvasId == canvasId);
.filter((ws) => ws.canvasId === canvasId);
SocketServer.broadcastSelected(clients, data);
}
}
@ -408,9 +407,9 @@ class SocketServer {
while (!client.done) {
const ws = client.value;
if (ws.readyState === WebSocket.OPEN
&& ws.user
&& ws.user && ws.canvasId !== null
) {
const canvasId = ws.canvasId || 0;
const { canvasId } = ws;
const { ip } = ws.user;
// only count unique IPs per canvas
if (!ipsPerCanvas[canvasId]) {
@ -580,7 +579,7 @@ class SocketServer {
case REG_CANVAS_OP: {
const canvasId = hydrateRegCanvas(buffer);
if (!canvases[canvasId]) return;
if (ws.canvasId !== null && ws.canvasId !== canvasId) {
if (ws.canvasId !== canvasId) {
this.deleteAllChunks(ws);
}
ws.canvasId = canvasId;

View File

@ -122,7 +122,9 @@ class ChunkLoader {
}
}
});
this.bcRemoveChunks(remChunks);
if (remChunks.length) {
this.bcRemoveChunks(remChunks);
}
// eslint-disable-next-line no-console,max-len
console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`);
}