From 344784f27434ed505982ffc74558af98ebb1a5b9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 7 Dec 2022 00:58:06 -0800 Subject: [PATCH] Replay previous images to a client when it first connects so that the images are just as persistent as the comments --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8dadeab..0ee5e43 100644 --- a/index.js +++ b/index.js @@ -48,10 +48,13 @@ app.get('/index.html', (req, res) => { io.on('connection', (socket) => { - // Replay old comments to a newly-joining client + // Replay old comments and images to a newly-joining client state.comments.forEach((comment) => { socket.emit('comment', comment) }); + state.images.forEach((image) => { + socket.emit('image', image) + }); // When any client comments, send that to all clients (including sender) socket.on('comment', (comment) => { -- 2.43.0