Add useGroupStream hook

environments/review-streaming-wgs1pl/deployments/3677
Alex Gleason 2023-07-22 14:06:15 -05:00
rodzic 811a9af670
commit 4a4a2d1a87
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
4 zmienionych plików z 14 dodań i 12 usunięć

Wyświetl plik

@ -193,14 +193,10 @@ const connectTimelineStream = (
const connectHashtagStream = (id: string, tag: string, accept: (status: APIEntity) => boolean) =>
connectTimelineStream(`hashtag:${id}`, `hashtag&tag=${tag}`, null, accept);
const connectGroupStream = (id: string) =>
connectTimelineStream(`group:${id}`, `group&group=${id}`);
export {
STREAMING_CHAT_UPDATE,
STREAMING_FOLLOW_RELATIONSHIPS_UPDATE,
connectTimelineStream,
connectHashtagStream,
connectGroupStream,
type TimelineStreamOpts,
};

Wyświetl plik

@ -50,5 +50,6 @@ export { useCommunityStream } from './streaming/useCommunityStream';
export { usePublicStream } from './streaming/usePublicStream';
export { useDirectStream } from './streaming/useDirectStream';
export { useListStream } from './streaming/useListStream';
export { useGroupStream } from './streaming/useGroupStream';
export { useRemoteStream } from './streaming/useRemoteStream';
export { useNostrStream } from './streaming/useNostrStream';

Wyświetl plik

@ -0,0 +1,10 @@
import { useTimelineStream } from './useTimelineStream';
function useGroupStream(groupId: string) {
return useTimelineStream(
`group:${groupId}`,
`group&group=${groupId}`,
);
}
export { useGroupStream };

Wyświetl plik

@ -4,9 +4,8 @@ import { FormattedMessage, useIntl } from 'react-intl';
import { Link } from 'react-router-dom';
import { groupCompose, setGroupTimelineVisible, uploadCompose } from 'soapbox/actions/compose';
import { connectGroupStream } from 'soapbox/actions/streaming';
import { expandGroupFeaturedTimeline, expandGroupTimeline } from 'soapbox/actions/timelines';
import { useGroup } from 'soapbox/api/hooks';
import { useGroup, useGroupStream } from 'soapbox/api/hooks';
import { Avatar, HStack, Icon, Stack, Text, Toggle } from 'soapbox/components/ui';
import ComposeForm from 'soapbox/features/compose/components/compose-form';
import { useAppDispatch, useAppSelector, useDraggedFiles, useOwnAccount } from 'soapbox/hooks';
@ -49,16 +48,12 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
dispatch(setGroupTimelineVisible(composeId, !groupTimelineVisible));
};
useGroupStream(groupId);
useEffect(() => {
dispatch(expandGroupTimeline(groupId));
dispatch(expandGroupFeaturedTimeline(groupId));
dispatch(groupCompose(composeId, groupId));
const disconnect = dispatch(connectGroupStream(groupId));
return () => {
disconnect();
};
}, [groupId]);
if (!group) {