From 7b54988514191d4a16322847b1e006aadc11fa7f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2021 10:36:41 +0530 Subject: [PATCH] close #72: Hide unread badge when there aren't any messages --- src/app/organisms/channel/ChannelViewCmdBar.jsx | 2 +- src/util/matrixUtil.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/organisms/channel/ChannelViewCmdBar.jsx b/src/app/organisms/channel/ChannelViewCmdBar.jsx index 35dc0ac..3943576 100644 --- a/src/app/organisms/channel/ChannelViewCmdBar.jsx +++ b/src/app/organisms/channel/ChannelViewCmdBar.jsx @@ -312,7 +312,7 @@ function ChannelViewCmdBar({ roomId, roomTimeline, viewEvent }) { else if (searchTerm.match(/^[-]?(\|)$/)) searchTerm = 'neutral_face'; else if (searchTerm.match(/^[-]?(d|D)$/)) searchTerm = 'grin'; else if (searchTerm.match(/^[-]?(\/)$/)) searchTerm = 'frown'; - else if (searchTerm.match(/^[-]?(p|P)$/)) searchTerm = 'stick_out_tongue'; + else if (searchTerm.match(/^[-]?(p|P)$/)) searchTerm = 'stuck_out_tongue'; else if (searchTerm.match(/^'[-]?(\()$/)) searchTerm = 'cry'; else if (searchTerm.match(/^[-]?(x|X)$/)) searchTerm = 'dizzy_face'; else if (searchTerm.match(/^[-]?(\()$/)) searchTerm = 'pleading_face'; diff --git a/src/util/matrixUtil.js b/src/util/matrixUtil.js index 056ffef..1dbd5fb 100644 --- a/src/util/matrixUtil.js +++ b/src/util/matrixUtil.js @@ -48,6 +48,7 @@ async function isRoomAliasAvailable(alias) { function doesRoomHaveUnread(room) { const userId = initMatrix.matrixClient.getUserId(); const readUpToId = room.getEventReadUpTo(userId); + const supportEvents = ['m.room.message', 'm.room.encrypted', 'm.sticker']; if (room.timeline.length && room.timeline[room.timeline.length - 1].sender @@ -60,7 +61,10 @@ function doesRoomHaveUnread(room) { const event = room.timeline[i]; if (event.getId() === readUpToId) return false; - return true; + + if (supportEvents.includes(event.getType())) { + return true; + } } return true; }