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:
170
apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx
Normal file
170
apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx
Normal file
@@ -0,0 +1,170 @@
|
||||
import type { IMessage } from '@rocket.chat/core-typings';
|
||||
import { css } from '@rocket.chat/css-in-js';
|
||||
import { Box, ModalBackdrop, Skeleton } from '@rocket.chat/fuselage';
|
||||
import { useLocalStorage } from '@rocket.chat/fuselage-hooks';
|
||||
import {
|
||||
Contextualbar,
|
||||
ContextualbarHeader,
|
||||
ContextualbarAction,
|
||||
ContextualbarActions,
|
||||
ContextualbarClose,
|
||||
ContextualbarBack,
|
||||
ContextualbarInnerContent,
|
||||
ContextualbarDialog,
|
||||
} from '@rocket.chat/ui-client';
|
||||
import {
|
||||
useLayoutContextualBarExpanded,
|
||||
useToastMessageDispatch,
|
||||
useTranslation,
|
||||
useUserId,
|
||||
useRoomToolbox,
|
||||
} from '@rocket.chat/ui-contexts';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
import ThreadChat from './components/ThreadChat';
|
||||
import ThreadSkeleton from './components/ThreadSkeleton';
|
||||
import ThreadTitle from './components/ThreadTitle';
|
||||
import { useThreadMainMessageQuery } from './hooks/useThreadMainMessageQuery';
|
||||
import { useToggleFollowingThreadMutation } from './hooks/useToggleFollowingThreadMutation';
|
||||
import { useGoToThreadList } from '../../hooks/useGoToThreadList';
|
||||
import ChatProvider from '../../providers/ChatProvider';
|
||||
|
||||
export type ThreadProps = {
|
||||
tmid: IMessage['_id'];
|
||||
};
|
||||
|
||||
const Thread = ({ tmid }: ThreadProps) => {
|
||||
const goToThreadList = useGoToThreadList({ replace: true });
|
||||
const { closeTab } = useRoomToolbox();
|
||||
|
||||
const mainMessageQueryResult = useThreadMainMessageQuery(tmid, {
|
||||
onDelete: () => {
|
||||
closeTab();
|
||||
},
|
||||
});
|
||||
|
||||
const t = useTranslation();
|
||||
const dispatchToastMessage = useToastMessageDispatch();
|
||||
|
||||
const canExpand = useLayoutContextualBarExpanded();
|
||||
const [expanded, setExpanded] = useLocalStorage('expand-threads', false);
|
||||
|
||||
const uid = useUserId();
|
||||
const following = uid ? (mainMessageQueryResult.data?.replies?.includes(uid) ?? false) : false;
|
||||
const toggleFollowingMutation = useToggleFollowingThreadMutation({
|
||||
onError: (error) => {
|
||||
dispatchToastMessage({ type: 'error', message: error });
|
||||
},
|
||||
});
|
||||
|
||||
const handleBackdropClick = () => {
|
||||
closeTab();
|
||||
};
|
||||
|
||||
const handleGoBack = () => {
|
||||
goToThreadList();
|
||||
};
|
||||
|
||||
const handleToggleExpand = () => {
|
||||
setExpanded((expanded) => !expanded);
|
||||
};
|
||||
|
||||
const handleToggleFollowing = () => {
|
||||
const rid = mainMessageQueryResult.data?.rid;
|
||||
|
||||
if (!rid) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggleFollowingMutation.mutate({ rid, tmid, follow: !following });
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
closeTab();
|
||||
};
|
||||
|
||||
const isExpanded = canExpand && expanded;
|
||||
const portalTarget = isExpanded ? document.getElementById('main-content') : null;
|
||||
|
||||
const threadContent = (
|
||||
<Contextualbar
|
||||
rcx-thread-view
|
||||
className={
|
||||
isExpanded
|
||||
? css`
|
||||
max-width: 855px !important;
|
||||
@media (min-width: 780px) and (max-width: 1135px) {
|
||||
max-width: calc(100% - var(--sidebar-width)) !important;
|
||||
}
|
||||
`
|
||||
: undefined
|
||||
}
|
||||
position='absolute'
|
||||
display='flex'
|
||||
flexDirection='column'
|
||||
width='full'
|
||||
overflow='hidden'
|
||||
zIndex={100}
|
||||
insetBlock={0}
|
||||
border='none'
|
||||
>
|
||||
<ContextualbarHeader>
|
||||
<ContextualbarBack onClick={handleGoBack} />
|
||||
{(mainMessageQueryResult.isLoading && <Skeleton width='100%' />) ||
|
||||
(mainMessageQueryResult.isSuccess && <ThreadTitle mainMessage={mainMessageQueryResult.data} />) ||
|
||||
null}
|
||||
<ContextualbarActions>
|
||||
{canExpand && (
|
||||
<ContextualbarAction
|
||||
name={expanded ? 'arrow-collapse' : 'arrow-expand'}
|
||||
title={expanded ? t('Collapse') : t('Expand')}
|
||||
onClick={handleToggleExpand}
|
||||
/>
|
||||
)}
|
||||
<ContextualbarAction
|
||||
name={following ? 'bell' : 'bell-off'}
|
||||
title={following ? t('Following') : t('Not_Following')}
|
||||
disabled={!mainMessageQueryResult.isSuccess || toggleFollowingMutation.isPending}
|
||||
onClick={handleToggleFollowing}
|
||||
/>
|
||||
<ContextualbarClose onClick={handleClose} />
|
||||
</ContextualbarActions>
|
||||
</ContextualbarHeader>
|
||||
|
||||
{(mainMessageQueryResult.isLoading && <ThreadSkeleton />) ||
|
||||
(mainMessageQueryResult.isSuccess && (
|
||||
<ChatProvider tmid={tmid}>
|
||||
<ThreadChat mainMessage={mainMessageQueryResult.data} />
|
||||
</ChatProvider>
|
||||
)) ||
|
||||
null}
|
||||
</Contextualbar>
|
||||
);
|
||||
|
||||
return (
|
||||
<ContextualbarDialog>
|
||||
<ContextualbarInnerContent>
|
||||
{portalTarget ? (
|
||||
createPortal(
|
||||
<>
|
||||
<ModalBackdrop
|
||||
className={css`
|
||||
position: absolute !important;
|
||||
`}
|
||||
onClick={handleBackdropClick}
|
||||
/>
|
||||
{threadContent}
|
||||
</>,
|
||||
portalTarget,
|
||||
)
|
||||
) : (
|
||||
<Box flexGrow={1} position='relative'>
|
||||
{threadContent}
|
||||
</Box>
|
||||
)}
|
||||
</ContextualbarInnerContent>
|
||||
</ContextualbarDialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default Thread;
|
||||
Reference in New Issue
Block a user