snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
101
apps/meteor/client/sidebar/RoomList/RoomList.tsx
Normal file
101
apps/meteor/client/sidebar/RoomList/RoomList.tsx
Normal file
@@ -0,0 +1,101 @@
|
||||
import { Box } from '@rocket.chat/fuselage';
|
||||
import { useResizeObserver } from '@rocket.chat/fuselage-hooks';
|
||||
import { VirtualizedScrollbars } from '@rocket.chat/ui-client';
|
||||
import { useUserPreference, useUserId } from '@rocket.chat/ui-contexts';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { GroupedVirtuoso } from 'react-virtuoso';
|
||||
|
||||
import RoomListCollapser from './RoomListCollapser';
|
||||
import RoomListRow from './RoomListRow';
|
||||
import RoomListRowWrapper from './RoomListRowWrapper';
|
||||
import RoomListWrapper from './RoomListWrapper';
|
||||
import { useOpenedRoom } from '../../lib/RoomManager';
|
||||
import { useMoveCategoryPosition } from '../categories/hooks/useMoveCategoryPosition';
|
||||
import { useAvatarTemplate } from '../hooks/useAvatarTemplate';
|
||||
import { SIDEBAR_DYNAMIC_GROUP_KEYS } from '../hooks/useCategoryList';
|
||||
import { useCollapsedGroups } from '../hooks/useCollapsedGroups';
|
||||
import { usePreventDefault } from '../hooks/usePreventDefault';
|
||||
import { useRoomList } from '../hooks/useRoomList';
|
||||
import { useShortcutOpenMenu } from '../hooks/useShortcutOpenMenu';
|
||||
import { useTemplateByViewMode } from '../hooks/useTemplateByViewMode';
|
||||
|
||||
const canMoveGroup = (groups: { key: string }[], index: number, direction: 'up' | 'down'): boolean => {
|
||||
if (SIDEBAR_DYNAMIC_GROUP_KEYS.includes(groups[index].key)) return false;
|
||||
if (direction === 'down') return index + 1 < groups.length;
|
||||
return groups.slice(0, index).some((g) => !SIDEBAR_DYNAMIC_GROUP_KEYS.includes(g.key));
|
||||
};
|
||||
|
||||
const RoomList = () => {
|
||||
const { t } = useTranslation();
|
||||
const userId = useUserId();
|
||||
const isAnonymous = !userId;
|
||||
|
||||
const { collapsedGroups, handleClick, handleKeyDown } = useCollapsedGroups();
|
||||
const { groups, groupsCount, totalCount } = useRoomList({ collapsedGroups });
|
||||
const moveCategory = useMoveCategoryPosition();
|
||||
const avatarTemplate = useAvatarTemplate();
|
||||
const sideBarItemTemplate = useTemplateByViewMode();
|
||||
const { ref } = useResizeObserver<HTMLElement>({ debounceDelay: 100 });
|
||||
const openedRoom = useOpenedRoom() ?? '';
|
||||
const sidebarViewMode = useUserPreference<'extended' | 'medium' | 'condensed'>('sidebarViewMode') || 'extended';
|
||||
|
||||
const extended = sidebarViewMode === 'extended';
|
||||
const itemData = useMemo(
|
||||
() => ({
|
||||
extended,
|
||||
t,
|
||||
SidebarItemTemplate: sideBarItemTemplate,
|
||||
AvatarTemplate: avatarTemplate,
|
||||
openedRoom,
|
||||
sidebarViewMode,
|
||||
isAnonymous,
|
||||
userId,
|
||||
}),
|
||||
[avatarTemplate, extended, isAnonymous, openedRoom, sideBarItemTemplate, sidebarViewMode, t, userId],
|
||||
);
|
||||
|
||||
const allGroupKeys = useMemo(() => groups.map((group) => group.key), [groups]);
|
||||
|
||||
usePreventDefault(ref);
|
||||
useShortcutOpenMenu(ref);
|
||||
|
||||
return (
|
||||
<Box position='relative' overflow='hidden' height='full' ref={ref}>
|
||||
<VirtualizedScrollbars>
|
||||
<GroupedVirtuoso
|
||||
groupCounts={groupsCount}
|
||||
groupContent={(index) => {
|
||||
const group = groups[index];
|
||||
|
||||
const onMoveUp = () => moveCategory(allGroupKeys, group.key, 'up');
|
||||
const onMoveDown = () => moveCategory(allGroupKeys, group.key, 'down');
|
||||
|
||||
return (
|
||||
<RoomListCollapser
|
||||
group={group}
|
||||
canMoveUp={canMoveGroup(groups, index, 'up')}
|
||||
canMoveDown={canMoveGroup(groups, index, 'down')}
|
||||
onMoveUp={onMoveUp}
|
||||
onMoveDown={onMoveDown}
|
||||
onClick={() => handleClick(group.key)}
|
||||
onKeyDown={(e) => handleKeyDown(e, group.key)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
{...(totalCount > 0 && {
|
||||
itemContent: (index, groupIndex) => {
|
||||
const group = groups[groupIndex];
|
||||
const correctedIndex = index - groupsCount.slice(0, groupIndex).reduce((acc, count) => acc + count, 0);
|
||||
const item = group.rooms[correctedIndex];
|
||||
return item && <RoomListRow data={itemData} item={item} />;
|
||||
},
|
||||
})}
|
||||
components={{ Item: RoomListRowWrapper, List: RoomListWrapper }}
|
||||
/>
|
||||
</VirtualizedScrollbars>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default RoomList;
|
||||
Reference in New Issue
Block a user