close #72: Hide unread badge when there aren't any messages

This commit is contained in:
unknown 2021-08-26 10:36:41 +05:30
parent ec4da47af6
commit 7b54988514
2 changed files with 6 additions and 2 deletions

View file

@ -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';

View file

@ -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,8 +61,11 @@ function doesRoomHaveUnread(room) {
const event = room.timeline[i];
if (event.getId() === readUpToId) return false;
if (supportEvents.includes(event.getType())) {
return true;
}
}
return true;
}