From 079c5d77e9bf77f5034976bdf70a0ed6d7ac2c9c Mon Sep 17 00:00:00 2001 From: Ayes Date: Sat, 19 Nov 2022 00:25:36 +0200 Subject: [PATCH] Improved room list avatar code --- .../molecules/room-selector/RoomSelector.jsx | 34 +++++-------------- src/app/organisms/navigation/Selector.jsx | 5 +-- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/app/molecules/room-selector/RoomSelector.jsx b/src/app/molecules/room-selector/RoomSelector.jsx index 785e19eb..fa6daa9e 100644 --- a/src/app/molecules/room-selector/RoomSelector.jsx +++ b/src/app/molecules/room-selector/RoomSelector.jsx @@ -5,12 +5,10 @@ import './RoomSelector.scss'; import { twemojify } from '../../../util/twemojify'; import colorMXID from '../../../util/colorMXID'; -import initMatrix from '../../../client/initMatrix'; import Text from '../../atoms/text/Text'; import Avatar from '../../atoms/avatar/Avatar'; import NotificationBadge from '../../atoms/badge/NotificationBadge'; import { blurOnBubbling } from '../../atoms/button/script'; -import settings from '../../../client/state/settings'; function RoomSelectorWrapper({ isSelected, isMuted, isUnread, onClick, @@ -56,13 +54,6 @@ function RoomSelector({ isSelected, isMuted, isUnread, notificationCount, isAlert, options, onClick, onContextMenu, }) { - let avatarSrc; - if (settings.showRoomListAvatar) { - const mx = initMatrix.matrixClient; - const room = mx.getRoom(roomId); - avatarSrc = room.getAvatarUrl(mx.baseUrl, 24, 24, 'crop'); - } - return ( - {settings.showRoomListAvatar ? ( - - ) : ( - - )} + {twemojify(name)} {parentName && ( diff --git a/src/app/organisms/navigation/Selector.jsx b/src/app/organisms/navigation/Selector.jsx index cb1086ea..62c8a935 100644 --- a/src/app/organisms/navigation/Selector.jsx +++ b/src/app/organisms/navigation/Selector.jsx @@ -17,6 +17,7 @@ import SpaceOptions from '../../molecules/space-options/SpaceOptions'; import VerticalMenuIC from '../../../../public/res/ic/outlined/vertical-menu.svg'; import { useForceUpdate } from '../../hooks/useForceUpdate'; +import settings from '../../../client/state/settings'; function Selector({ roomId, isDM, drawerPostie, onClick, @@ -57,8 +58,8 @@ function Selector({ key={roomId} name={room.name} roomId={roomId} - imageSrc={isDM ? imageSrc : null} - iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule(), room.isSpaceRoom())} + imageSrc={isDM || settings.showRoomListAvatar ? imageSrc : null} + iconSrc={isDM || settings.showRoomListAvatar ? null : joinRuleToIconSrc(room.getJoinRule(), room.isSpaceRoom())} isSelected={navigation.selectedRoomId === roomId} isMuted={isMuted} isUnread={!isMuted && noti.hasNoti(roomId)}