diff --git a/src/app/organisms/navigation/Selector.jsx b/src/app/organisms/navigation/Selector.jsx index 3a1bc162..049b505e 100644 --- a/src/app/organisms/navigation/Selector.jsx +++ b/src/app/organisms/navigation/Selector.jsx @@ -6,18 +6,13 @@ import initMatrix from '../../../client/initMatrix'; import navigation from '../../../client/state/navigation'; import { openReusableContextMenu } from '../../../client/action/navigation'; import { getEventCords, abbreviateNumber } from '../../../util/common'; +import { joinRuleToIconSrc } from '../../../util/matrixUtil'; import IconButton from '../../atoms/button/IconButton'; import RoomSelector from '../../molecules/room-selector/RoomSelector'; import RoomOptions from '../../molecules/room-options/RoomOptions'; import SpaceOptions from '../../molecules/space-options/SpaceOptions'; -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 VerticalMenuIC from '../../../../public/res/ic/outlined/vertical-menu.svg'; function Selector({ @@ -59,19 +54,13 @@ function Selector({ ); }; - const joinRuleToIconSrc = (joinRule) => ({ - restricted: () => (room.isSpaceRoom() ? SpaceIC : HashIC), - invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC), - public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC), - }[joinRule]?.() || null); - return ( ({ - 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()); + iconSrc = joinRuleToIconSrc(item.room.getJoinRule(), item.type === 'space'); } const isUnread = notifs.hasNoti(item.roomId); diff --git a/src/util/matrixUtil.js b/src/util/matrixUtil.js index 5c40fa91..f52117b6 100644 --- a/src/util/matrixUtil.js +++ b/src/util/matrixUtil.js @@ -1,5 +1,12 @@ import initMatrix from '../client/initMatrix'; +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'; + const WELL_KNOWN_URI = '/.well-known/matrix/client'; async function getBaseUrl(servername) { @@ -86,8 +93,16 @@ function hasDMWith(userId) { }); } +function joinRuleToIconSrc(joinRule, isSpace) { + return ({ + restricted: () => (isSpace ? SpaceIC : HashIC), + invite: () => (isSpace ? SpaceLockIC : HashLockIC), + public: () => (isSpace ? SpaceGlobeIC : HashGlobeIC), + }[joinRule]?.() || null); +} + export { getBaseUrl, getUsername, getUsernameOfRoomMember, isRoomAliasAvailable, getPowerLabel, parseReply, - hasDMWith, + hasDMWith, joinRuleToIconSrc, };