kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Add useDirectStream hook
rodzic
9b1352f0ad
commit
4090d6ab51
|
@ -193,9 +193,6 @@ const connectTimelineStream = (
|
||||||
const connectHashtagStream = (id: string, tag: string, accept: (status: APIEntity) => boolean) =>
|
const connectHashtagStream = (id: string, tag: string, accept: (status: APIEntity) => boolean) =>
|
||||||
connectTimelineStream(`hashtag:${id}`, `hashtag&tag=${tag}`, null, accept);
|
connectTimelineStream(`hashtag:${id}`, `hashtag&tag=${tag}`, null, accept);
|
||||||
|
|
||||||
const connectDirectStream = () =>
|
|
||||||
connectTimelineStream('direct', 'direct');
|
|
||||||
|
|
||||||
const connectListStream = (id: string) =>
|
const connectListStream = (id: string) =>
|
||||||
connectTimelineStream(`list:${id}`, `list&list=${id}`);
|
connectTimelineStream(`list:${id}`, `list&list=${id}`);
|
||||||
|
|
||||||
|
@ -207,7 +204,6 @@ export {
|
||||||
STREAMING_FOLLOW_RELATIONSHIPS_UPDATE,
|
STREAMING_FOLLOW_RELATIONSHIPS_UPDATE,
|
||||||
connectTimelineStream,
|
connectTimelineStream,
|
||||||
connectHashtagStream,
|
connectHashtagStream,
|
||||||
connectDirectStream,
|
|
||||||
connectListStream,
|
connectListStream,
|
||||||
connectGroupStream,
|
connectGroupStream,
|
||||||
type TimelineStreamOpts,
|
type TimelineStreamOpts,
|
||||||
|
|
|
@ -48,5 +48,6 @@ export { useUpdateGroupTag } from './groups/useUpdateGroupTag';
|
||||||
export { useUserStream } from './streaming/useUserStream';
|
export { useUserStream } from './streaming/useUserStream';
|
||||||
export { useCommunityStream } from './streaming/useCommunityStream';
|
export { useCommunityStream } from './streaming/useCommunityStream';
|
||||||
export { usePublicStream } from './streaming/usePublicStream';
|
export { usePublicStream } from './streaming/usePublicStream';
|
||||||
|
export { useDirectStream } from './streaming/useDirectStream';
|
||||||
export { useRemoteStream } from './streaming/useRemoteStream';
|
export { useRemoteStream } from './streaming/useRemoteStream';
|
||||||
export { useNostrStream } from './streaming/useNostrStream';
|
export { useNostrStream } from './streaming/useNostrStream';
|
|
@ -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 { directComposeById } from 'soapbox/actions/compose';
|
||||||
import { mountConversations, unmountConversations, expandConversations } from 'soapbox/actions/conversations';
|
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 AccountSearch from 'soapbox/components/account-search';
|
||||||
import { Column } from 'soapbox/components/ui';
|
import { Column } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
|
@ -19,15 +19,14 @@ const ConversationsTimeline = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
useDirectStream();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(mountConversations());
|
dispatch(mountConversations());
|
||||||
dispatch(expandConversations());
|
dispatch(expandConversations());
|
||||||
|
|
||||||
const disconnect = dispatch(connectDirectStream());
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
dispatch(unmountConversations());
|
dispatch(unmountConversations());
|
||||||
disconnect();
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ import React, { useEffect } from 'react';
|
||||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { directComposeById } from 'soapbox/actions/compose';
|
import { directComposeById } from 'soapbox/actions/compose';
|
||||||
import { connectDirectStream } from 'soapbox/actions/streaming';
|
|
||||||
import { expandDirectTimeline } from 'soapbox/actions/timelines';
|
import { expandDirectTimeline } from 'soapbox/actions/timelines';
|
||||||
|
import { useDirectStream } from 'soapbox/api/hooks';
|
||||||
import AccountSearch from 'soapbox/components/account-search';
|
import AccountSearch from 'soapbox/components/account-search';
|
||||||
import { Column } from 'soapbox/components/ui';
|
import { Column } from 'soapbox/components/ui';
|
||||||
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
|
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
|
||||||
|
@ -20,13 +20,10 @@ const DirectTimeline = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const next = useAppSelector(state => state.timelines.get('direct')?.next);
|
const next = useAppSelector(state => state.timelines.get('direct')?.next);
|
||||||
|
|
||||||
|
useDirectStream();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(expandDirectTimeline());
|
dispatch(expandDirectTimeline());
|
||||||
const disconnect = dispatch(connectDirectStream());
|
|
||||||
|
|
||||||
return (() => {
|
|
||||||
disconnect();
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSuggestion = (accountId: string) => {
|
const handleSuggestion = (accountId: string) => {
|
||||||
|
|
Ładowanie…
Reference in New Issue