diff --git a/src/app/organisms/navigation/Selector.jsx b/src/app/organisms/navigation/Selector.jsx index b54f1a61..80a03574 100644 --- a/src/app/organisms/navigation/Selector.jsx +++ b/src/app/organisms/navigation/Selector.jsx @@ -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))} diff --git a/src/app/organisms/search/Search.jsx b/src/app/organisms/search/Search.jsx index b03c8016..2a707424 100644 --- a/src/app/organisms/search/Search.jsx +++ b/src/app/organisms/search/Search.jsx @@ -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);