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), restricted: () => (room.isSpaceRoom() ? SpaceIC : HashIC),
invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC), invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC),
public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC), public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC),
}; }[joinRule]?.() || null);
if (room.isSpaceRoom()) { if (room.isSpaceRoom()) {
return ( return (
@ -61,7 +61,7 @@ function Selector({
key={roomId} key={roomId}
name={room.name} name={room.name}
roomId={roomId} roomId={roomId}
iconSrc={joinRuleToIconSrc[room.getJoinRule()]?.() || null} iconSrc={joinRuleToIconSrc(room.getJoinRule())}
isUnread={noti.hasNoti(roomId)} isUnread={noti.hasNoti(roomId)}
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))} notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
isAlert={noti.getHighlightNoti(roomId) !== 0} isAlert={noti.getHighlightNoti(roomId) !== 0}
@ -90,7 +90,7 @@ function Selector({
name={room.name} name={room.name}
roomId={roomId} roomId={roomId}
imageSrc={isDM ? imageSrc : null} imageSrc={isDM ? imageSrc : null}
iconSrc={isDM ? null : joinRuleToIconSrc[room.getJoinRule()]?.() || null} iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule())}
isSelected={isSelected} isSelected={isSelected}
isUnread={noti.hasNoti(roomId)} isUnread={noti.hasNoti(roomId)}
notificationCount={abbreviateNumber(noti.getTotalNoti(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 SearchIC from '../../../../public/res/ic/outlined/search.svg';
import HashIC from '../../../../public/res/ic/outlined/hash.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 HashLockIC from '../../../../public/res/ic/outlined/hash-lock.svg';
import SpaceIC from '../../../../public/res/ic/outlined/space.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 SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg';
import CrossIC from '../../../../public/res/ic/outlined/cross.svg'; import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
@ -176,12 +178,18 @@ function Search() {
const notifs = initMatrix.notifications; const notifs = initMatrix.notifications;
const renderRoomSelector = (item) => { const renderRoomSelector = (item) => {
const isPrivate = item.room.getJoinRule() === 'invite';
let imageSrc = null; let imageSrc = null;
let iconSrc = null; let iconSrc = null;
if (item.type === 'room') iconSrc = isPrivate ? HashLockIC : HashIC; if (item.type === 'direct') {
if (item.type === 'space') iconSrc = isPrivate ? SpaceLockIC : SpaceIC; 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 isUnread = notifs.hasNoti(item.roomId);
const noti = notifs.getNoti(item.roomId); const noti = notifs.getNoti(item.roomId);