diff --git a/lib/www/client/source/src/main.js b/lib/www/client/source/src/main.js index 023f0c3..4f1c35e 100644 --- a/lib/www/client/source/src/main.js +++ b/lib/www/client/source/src/main.js @@ -51,9 +51,6 @@ new Vue({ this.ws.addEventListener("message", (ev) => { const msg = JSON.parse(ev.data); - if (msg.payload) { - msg.payload = JSON.parse(msg.payload); - } this.setServerEvent(msg); }); diff --git a/lib/www/server/ws/db.js b/lib/www/server/ws/db.js index a26559b..028cdef 100644 --- a/lib/www/server/ws/db.js +++ b/lib/www/server/ws/db.js @@ -7,6 +7,12 @@ const channels = {}; async function notify (data) { if (data.channel in channels) { data._received = new Date(); + try { + const json = JSON.parse(data.payload); + data.payload = json; + } catch { + // Ignore the error + } for (const listener of channels[data.channel]) { listener(data); }