Improved room list avatar code
This commit is contained in:
parent
dd22a92e33
commit
079c5d77e9
2 changed files with 11 additions and 28 deletions
|
@ -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,23 +61,14 @@ function RoomSelector({
|
|||
isUnread={isUnread}
|
||||
content={(
|
||||
<>
|
||||
{settings.showRoomListAvatar ? (
|
||||
<Avatar
|
||||
text={name}
|
||||
bgColor={colorMXID(roomId)}
|
||||
imageSrc={avatarSrc}
|
||||
size="extra-small"
|
||||
/>
|
||||
) : (
|
||||
<Avatar
|
||||
text={name}
|
||||
bgColor={colorMXID(roomId)}
|
||||
imageSrc={imageSrc}
|
||||
iconColor="var(--ic-surface-low)"
|
||||
iconSrc={iconSrc}
|
||||
size="extra-small"
|
||||
/>
|
||||
)}
|
||||
<Avatar
|
||||
text={name}
|
||||
bgColor={colorMXID(roomId)}
|
||||
imageSrc={imageSrc}
|
||||
iconColor="var(--ic-surface-low)"
|
||||
iconSrc={iconSrc}
|
||||
size="extra-small"
|
||||
/>
|
||||
<Text variant="b1" weight={isUnread ? 'medium' : 'normal'}>
|
||||
{twemojify(name)}
|
||||
{parentName && (
|
||||
|
|
|
@ -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)}
|
||||
|
|
Loading…
Reference in a new issue