From 8fe1679acccc5c77f788d5f0d46415d0e117cd7d Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Sun, 23 Jan 2022 10:46:44 -0600 Subject: [PATCH] message updates --- src/render/components/bubble.js | 2 +- src/render/components/messenger.js | 14 ++++++++++++-- src/session.js | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/render/components/bubble.js b/src/render/components/bubble.js index 1eaa48e..87d9897 100644 --- a/src/render/components/bubble.js +++ b/src/render/components/bubble.js @@ -33,4 +33,4 @@ const Bubble = export default Bubble; -// TODO: should include other styling/actions for audio bubbles \ No newline at end of file +// TODO: should include other styling/actions for audio bubbles diff --git a/src/render/components/messenger.js b/src/render/components/messenger.js index 6a1e9a2..def7fcd 100644 --- a/src/render/components/messenger.js +++ b/src/render/components/messenger.js @@ -37,9 +37,17 @@ const Messenger = { { messages.value.push(update); } - else + else if (typeof update == Array) { - messages.value[messages.value.length - 1].content.push(update); + messages.value.push(...update); + } + else if (update.category) + { + search(update.message).content.push(update); + } + else if (update.context) + { + search(update.message).context = update.context; } }); @@ -52,6 +60,8 @@ const Messenger = { messages.value = []; }); + const search = (id) => messages.value.find(m => m.id == id); + return { person, messages, onDrop }; }, diff --git a/src/session.js b/src/session.js index 3d6ccdf..d2e4a2a 100644 --- a/src/session.js +++ b/src/session.js @@ -26,6 +26,8 @@ function handleMessageQueue() { const update = messageQueue.shift(); + console.log(update); + if (update) { if (update.person) @@ -40,20 +42,30 @@ function handleMessageQueue() { ui.messages.push(update); } + else if (typeof update == Array) + { + ui.messages.push(...update); + } else if (update.category) { - ui.messages[ui.messages.length - 1].content.push(update); + search(update.message).content.push(update); } - else + else if (update.title) { new Notification(update).show(); return; } + else if (update.context) + { + search(update.message).context = update.context; + } ipcEmit("message", update); } } } +const search = (id) => ui.messages.find(m => m.id == id); + function launchSession(account) { connectToPlatform(account); -- 2.43.0