Add globe icons in search

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-05 17:47:41 +05:30
parent 6388894aa4
commit c304670f47
2 changed files with 16 additions and 8 deletions

View file

@ -49,11 +49,11 @@ function Selector({
};
}, []);
const joinRuleToIconSrc = {
const joinRuleToIconSrc = (joinRule) => ({
restricted: () => (room.isSpaceRoom() ? SpaceIC : HashIC),
invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC),
public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC),
};
}[joinRule]?.() || null);
if (room.isSpaceRoom()) {
return (
@ -61,7 +61,7 @@ function Selector({
key={roomId}
name={room.name}
roomId={roomId}
iconSrc={joinRuleToIconSrc[room.getJoinRule()]?.() || null}
iconSrc={joinRuleToIconSrc(room.getJoinRule())}
isUnread={noti.hasNoti(roomId)}
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
isAlert={noti.getHighlightNoti(roomId) !== 0}
@ -90,7 +90,7 @@ function Selector({
name={room.name}
roomId={roomId}
imageSrc={isDM ? imageSrc : null}
iconSrc={isDM ? null : joinRuleToIconSrc[room.getJoinRule()]?.() || null}
iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule())}
isSelected={isSelected}
isUnread={noti.hasNoti(roomId)}
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}

View file

@ -17,8 +17,10 @@ import RoomSelector from '../../molecules/room-selector/RoomSelector';
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
import HashIC from '../../../../public/res/ic/outlined/hash.svg';
import HashGlobeIC from '../../../../public/res/ic/outlined/hash-globe.svg';
import HashLockIC from '../../../../public/res/ic/outlined/hash-lock.svg';
import SpaceIC from '../../../../public/res/ic/outlined/space.svg';
import SpaceGlobeIC from '../../../../public/res/ic/outlined/space-globe.svg';
import SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg';
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
@ -176,12 +178,18 @@ function Search() {
const notifs = initMatrix.notifications;
const renderRoomSelector = (item) => {
const isPrivate = item.room.getJoinRule() === 'invite';
let imageSrc = null;
let iconSrc = null;
if (item.type === 'room') iconSrc = isPrivate ? HashLockIC : HashIC;
if (item.type === 'space') iconSrc = isPrivate ? SpaceLockIC : SpaceIC;
if (item.type === 'direct') imageSrc = item.room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
if (item.type === 'direct') {
imageSrc = item.room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
} else {
const joinRuleToIconSrc = (joinRule) => ({
restricted: () => (item.type === 'space' ? SpaceIC : HashIC),
invite: () => (item.type === 'space' ? SpaceLockIC : HashLockIC),
public: () => (item.type === 'space' ? SpaceGlobeIC : HashGlobeIC),
}[joinRule]?.() || null);
iconSrc = joinRuleToIconSrc(item.room.getJoinRule());
}
const isUnread = notifs.hasNoti(item.roomId);
const noti = notifs.getNoti(item.roomId);