diff --git a/app/soapbox/actions/streaming.ts b/app/soapbox/actions/streaming.ts index 1d71d8d98d..1367187eb8 100644 --- a/app/soapbox/actions/streaming.ts +++ b/app/soapbox/actions/streaming.ts @@ -193,9 +193,6 @@ const connectTimelineStream = ( const connectHashtagStream = (id: string, tag: string, accept: (status: APIEntity) => boolean) => connectTimelineStream(`hashtag:${id}`, `hashtag&tag=${tag}`, null, accept); -const connectListStream = (id: string) => - connectTimelineStream(`list:${id}`, `list&list=${id}`); - const connectGroupStream = (id: string) => connectTimelineStream(`group:${id}`, `group&group=${id}`); @@ -204,7 +201,6 @@ export { STREAMING_FOLLOW_RELATIONSHIPS_UPDATE, connectTimelineStream, connectHashtagStream, - connectListStream, connectGroupStream, type TimelineStreamOpts, }; diff --git a/app/soapbox/api/hooks/index.ts b/app/soapbox/api/hooks/index.ts index 214607f6d1..1983c59f2f 100644 --- a/app/soapbox/api/hooks/index.ts +++ b/app/soapbox/api/hooks/index.ts @@ -49,5 +49,6 @@ export { useUserStream } from './streaming/useUserStream'; export { useCommunityStream } from './streaming/useCommunityStream'; export { usePublicStream } from './streaming/usePublicStream'; export { useDirectStream } from './streaming/useDirectStream'; +export { useListStream } from './streaming/useListStream'; export { useRemoteStream } from './streaming/useRemoteStream'; export { useNostrStream } from './streaming/useNostrStream'; \ No newline at end of file diff --git a/app/soapbox/api/hooks/streaming/useListStream.ts b/app/soapbox/api/hooks/streaming/useListStream.ts new file mode 100644 index 0000000000..f38b0209c1 --- /dev/null +++ b/app/soapbox/api/hooks/streaming/useListStream.ts @@ -0,0 +1,10 @@ +import { useTimelineStream } from './useTimelineStream'; + +function useListStream(listId: string) { + return useTimelineStream( + `list:${listId}`, + `list&list=${listId}`, + ); +} + +export { useListStream }; \ No newline at end of file diff --git a/app/soapbox/features/list-timeline/index.tsx b/app/soapbox/features/list-timeline/index.tsx index f16acf18b6..e9b56aadae 100644 --- a/app/soapbox/features/list-timeline/index.tsx +++ b/app/soapbox/features/list-timeline/index.tsx @@ -4,8 +4,8 @@ import { useParams } from 'react-router-dom'; import { fetchList } from 'soapbox/actions/lists'; import { openModal } from 'soapbox/actions/modals'; -import { connectListStream } from 'soapbox/actions/streaming'; import { expandListTimeline } from 'soapbox/actions/timelines'; +import { useListStream } from 'soapbox/api/hooks'; import MissingIndicator from 'soapbox/components/missing-indicator'; import { Column, Button, Spinner } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; @@ -19,15 +19,11 @@ const ListTimeline: React.FC = () => { const list = useAppSelector((state) => state.lists.get(id)); const next = useAppSelector(state => state.timelines.get(`list:${id}`)?.next); + useListStream(id); + useEffect(() => { dispatch(fetchList(id)); dispatch(expandListTimeline(id)); - - const disconnect = dispatch(connectListStream(id)); - - return () => { - disconnect(); - }; }, [id]); const handleLoadMore = (maxId: string) => {