From 3867cece408bd8d07ff24e72b580ef0b068e5ab9 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 23 Feb 2022 18:31:49 +0000 Subject: [PATCH] client: tidy up error message handling --- client/devtools.js | 2 +- client/index.js | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/client/devtools.js b/client/devtools.js index 23bdde7..9ed4ff6 100644 --- a/client/devtools.js +++ b/client/devtools.js @@ -13,10 +13,10 @@ export function bandwidth(domNode, conn) { /** * Generate an SVG visualisation of the sliding lists and attaches it as a child to the domNode provided. + * Does nothing if there are no resp.ops. * @param {Element} domNode The node to insert the SVG into. * @param {[]SlidingList} activeLists The lists * @param {object} resp The Sliding Sync response JSON - * @returns {SVGSVGElement} */ export function svgify(domNode, activeLists, resp) { if (resp.ops.length === 0) { diff --git a/client/index.js b/client/index.js index f965cfc..0a16b59 100644 --- a/client/index.js +++ b/client/index.js @@ -3,7 +3,6 @@ import { SlidingList, SlidingSyncConnection } from './sync.js'; import * as render from './render.js'; import * as devtools from './devtools.js'; -let lastError = null; let activeSessionId; let activeRoomId = ""; // the room currently being viewed let syncConnection = new SlidingSyncConnection(); @@ -366,7 +365,6 @@ const doSyncLoop = async (accessToken, sessionId) => { console.log("Starting sync loop. Active: ", activeSessionId, " this:", sessionId); let currentPos; - let currentError = null; let currentSub = ""; while (sessionId === activeSessionId) { let resp; @@ -416,14 +414,12 @@ const doSyncLoop = async (accessToken, sessionId) => { activeLists[index].joinedCount = count; }); } + // reset any error message + document.getElementById("errorMsg").textContent = ""; } catch (err) { if (err.name !== "AbortError") { console.error("/sync failed:", err); - console.log("current", currentError, "last", lastError); - if (currentError != lastError) { - document.getElementById("errorMsg").textContent = lastError ? lastError : ""; - } - currentError = lastError; + document.getElementById("errorMsg").textContent = err; await sleep(3000); } }