Add join rle to icon src util function
Signed-off-by: ajbura <ajbura@gmail.com>
This commit is contained in:
parent
76cb52878c
commit
189dc93a6e
3 changed files with 20 additions and 26 deletions
|
@ -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 (
|
||||
<RoomSelector
|
||||
key={roomId}
|
||||
name={room.name}
|
||||
roomId={roomId}
|
||||
imageSrc={isDM ? imageSrc : null}
|
||||
iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule())}
|
||||
iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule(), room.isSpaceRoom())}
|
||||
isSelected={isSelected}
|
||||
isUnread={noti.hasNoti(roomId)}
|
||||
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cons from '../../../client/state/cons';
|
|||
import navigation from '../../../client/state/navigation';
|
||||
import AsyncSearch from '../../../util/AsyncSearch';
|
||||
import { selectRoom, selectTab } from '../../../client/action/navigation';
|
||||
import { joinRuleToIconSrc } from '../../../util/matrixUtil';
|
||||
|
||||
import Text from '../../atoms/text/Text';
|
||||
import RawIcon from '../../atoms/system-icons/RawIcon';
|
||||
|
@ -16,12 +17,6 @@ import ScrollView from '../../atoms/scroll/ScrollView';
|
|||
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';
|
||||
|
||||
function useVisiblityToggle(setResult) {
|
||||
|
@ -183,12 +178,7 @@ function Search() {
|
|||
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());
|
||||
iconSrc = joinRuleToIconSrc(item.room.getJoinRule(), item.type === 'space');
|
||||
}
|
||||
|
||||
const isUnread = notifs.hasNoti(item.roomId);
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue