From 52cc76f6761def85b91101aa3244a931b95c177c Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sat, 24 Sep 2022 17:07:50 +0300 Subject: [PATCH] display channel name in title --- frontend/src/stores.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/stores.js b/frontend/src/stores.js index 6594fc1..51c6fd4 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -606,13 +606,20 @@ selectedChannel.watch((newSelectedChannel) => { } }); -unreadStore.subscribe(() => { + +const updateTitle = () => { let totalUnreads = 0; unreadStore.value.forEach(count => totalUnreads += count); + let channelSuffix = ""; + if (selectedChannel.value && selectedChannel.value.id !== -1 && selectedChannel.value.name) { + channelSuffix = ` | #${selectedChannel.value.name}`; + } if (totalUnreads > 0) { - window.document.title = `(${totalUnreads}) waffle`; + window.document.title = `(${totalUnreads}) waffle${channelSuffix}`; } else { - window.document.title = "waffle"; + window.document.title = `waffle${channelSuffix}`; } -}); +}; +unreadStore.subscribe(updateTitle); +selectedChannel.subscribe(updateTitle);