Improved room list avatar code

This commit is contained in:
Ayes 2022-11-19 00:25:36 +02:00
parent dd22a92e33
commit 079c5d77e9
2 changed files with 11 additions and 28 deletions

View file

@ -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 (
<RoomSelectorWrapper
isSelected={isSelected}
@ -70,14 +61,6 @@ function RoomSelector({
isUnread={isUnread}
content={(
<>
{settings.showRoomListAvatar ? (
<Avatar
text={name}
bgColor={colorMXID(roomId)}
imageSrc={avatarSrc}
size="extra-small"
/>
) : (
<Avatar
text={name}
bgColor={colorMXID(roomId)}
@ -86,7 +69,6 @@ function RoomSelector({
iconSrc={iconSrc}
size="extra-small"
/>
)}
<Text variant="b1" weight={isUnread ? 'medium' : 'normal'}>
{twemojify(name)}
{parentName && (

View file

@ -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)}