Add useDirectStream hook
This commit is contained in:
parent
9b1352f0ad
commit
4090d6ab51
5 changed files with 14 additions and 14 deletions
|
@ -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 connectDirectStream = () =>
|
||||
connectTimelineStream('direct', 'direct');
|
||||
|
||||
const connectListStream = (id: string) =>
|
||||
connectTimelineStream(`list:${id}`, `list&list=${id}`);
|
||||
|
||||
|
@ -207,7 +204,6 @@ export {
|
|||
STREAMING_FOLLOW_RELATIONSHIPS_UPDATE,
|
||||
connectTimelineStream,
|
||||
connectHashtagStream,
|
||||
connectDirectStream,
|
||||
connectListStream,
|
||||
connectGroupStream,
|
||||
type TimelineStreamOpts,
|
||||
|
|
|
@ -48,5 +48,6 @@ export { useUpdateGroupTag } from './groups/useUpdateGroupTag';
|
|||
export { useUserStream } from './streaming/useUserStream';
|
||||
export { useCommunityStream } from './streaming/useCommunityStream';
|
||||
export { usePublicStream } from './streaming/usePublicStream';
|
||||
export { useDirectStream } from './streaming/useDirectStream';
|
||||
export { useRemoteStream } from './streaming/useRemoteStream';
|
||||
export { useNostrStream } from './streaming/useNostrStream';
|
7
app/soapbox/api/hooks/streaming/useDirectStream.ts
Normal file
7
app/soapbox/api/hooks/streaming/useDirectStream.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { useTimelineStream } from './useTimelineStream';
|
||||
|
||||
function useDirectStream() {
|
||||
return useTimelineStream('direct', 'direct');
|
||||
}
|
||||
|
||||
export { useDirectStream };
|
|
@ -3,7 +3,7 @@ import { defineMessages, useIntl } from 'react-intl';
|
|||
|
||||
import { directComposeById } from 'soapbox/actions/compose';
|
||||
import { mountConversations, unmountConversations, expandConversations } from 'soapbox/actions/conversations';
|
||||
import { connectDirectStream } from 'soapbox/actions/streaming';
|
||||
import { useDirectStream } from 'soapbox/api/hooks';
|
||||
import AccountSearch from 'soapbox/components/account-search';
|
||||
import { Column } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
|
@ -19,15 +19,14 @@ const ConversationsTimeline = () => {
|
|||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
useDirectStream();
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(mountConversations());
|
||||
dispatch(expandConversations());
|
||||
|
||||
const disconnect = dispatch(connectDirectStream());
|
||||
|
||||
return () => {
|
||||
dispatch(unmountConversations());
|
||||
disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ import React, { useEffect } from 'react';
|
|||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { directComposeById } from 'soapbox/actions/compose';
|
||||
import { connectDirectStream } from 'soapbox/actions/streaming';
|
||||
import { expandDirectTimeline } from 'soapbox/actions/timelines';
|
||||
import { useDirectStream } from 'soapbox/api/hooks';
|
||||
import AccountSearch from 'soapbox/components/account-search';
|
||||
import { Column } from 'soapbox/components/ui';
|
||||
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
|
||||
|
@ -20,13 +20,10 @@ const DirectTimeline = () => {
|
|||
const dispatch = useAppDispatch();
|
||||
const next = useAppSelector(state => state.timelines.get('direct')?.next);
|
||||
|
||||
useDirectStream();
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(expandDirectTimeline());
|
||||
const disconnect = dispatch(connectDirectStream());
|
||||
|
||||
return (() => {
|
||||
disconnect();
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleSuggestion = (accountId: string) => {
|
||||
|
|
Loading…
Reference in a new issue