Streaming: allow connecting if not logged in, gate certain topics
This commit is contained in:
parent
53c8858fa6
commit
85c8f674b4
5 changed files with 41 additions and 6 deletions
|
@ -1,7 +1,17 @@
|
||||||
|
import { useLoggedIn } from 'soapbox/hooks';
|
||||||
|
|
||||||
import { useTimelineStream } from './useTimelineStream';
|
import { useTimelineStream } from './useTimelineStream';
|
||||||
|
|
||||||
function useDirectStream() {
|
function useDirectStream() {
|
||||||
return useTimelineStream('direct', 'direct');
|
const { isLoggedIn } = useLoggedIn();
|
||||||
|
|
||||||
|
return useTimelineStream(
|
||||||
|
'direct',
|
||||||
|
'direct',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ enabled: isLoggedIn },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useDirectStream };
|
export { useDirectStream };
|
|
@ -1,9 +1,16 @@
|
||||||
|
import { useLoggedIn } from 'soapbox/hooks';
|
||||||
|
|
||||||
import { useTimelineStream } from './useTimelineStream';
|
import { useTimelineStream } from './useTimelineStream';
|
||||||
|
|
||||||
function useListStream(listId: string) {
|
function useListStream(listId: string) {
|
||||||
|
const { isLoggedIn } = useLoggedIn();
|
||||||
|
|
||||||
return useTimelineStream(
|
return useTimelineStream(
|
||||||
`list:${listId}`,
|
`list:${listId}`,
|
||||||
`list&list=${listId}`,
|
`list&list=${listId}`,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ enabled: isLoggedIn },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
import { useFeatures } from 'soapbox/hooks';
|
import { useFeatures, useLoggedIn } from 'soapbox/hooks';
|
||||||
|
|
||||||
import { useTimelineStream } from './useTimelineStream';
|
import { useTimelineStream } from './useTimelineStream';
|
||||||
|
|
||||||
function useNostrStream() {
|
function useNostrStream() {
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const enabled = features.nostrSign && Boolean(window.nostr);
|
const { isLoggedIn } = useLoggedIn();
|
||||||
return useTimelineStream('nostr', 'nostr', null, null, { enabled });
|
|
||||||
|
return useTimelineStream(
|
||||||
|
'nostr',
|
||||||
|
'nostr',
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
enabled: isLoggedIn && features.nostrSign && Boolean(window.nostr),
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { useNostrStream };
|
export { useNostrStream };
|
|
@ -17,7 +17,7 @@ function useTimelineStream(...args: Parameters<typeof connectTimelineStream>) {
|
||||||
const streamingUrl = instance.urls.get('streaming_api');
|
const streamingUrl = instance.urls.get('streaming_api');
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
if (enabled && accessToken && streamingUrl && !stream.current) {
|
if (enabled && streamingUrl && !stream.current) {
|
||||||
stream.current = dispatch(connectTimelineStream(...args));
|
stream.current = dispatch(connectTimelineStream(...args));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,14 +2,23 @@ import { fetchAnnouncements } from 'soapbox/actions/announcements';
|
||||||
import { expandNotifications } from 'soapbox/actions/notifications';
|
import { expandNotifications } from 'soapbox/actions/notifications';
|
||||||
import { expandHomeTimeline } from 'soapbox/actions/timelines';
|
import { expandHomeTimeline } from 'soapbox/actions/timelines';
|
||||||
import { useStatContext } from 'soapbox/contexts/stat-context';
|
import { useStatContext } from 'soapbox/contexts/stat-context';
|
||||||
|
import { useLoggedIn } from 'soapbox/hooks';
|
||||||
|
|
||||||
import { useTimelineStream } from './useTimelineStream';
|
import { useTimelineStream } from './useTimelineStream';
|
||||||
|
|
||||||
import type { AppDispatch } from 'soapbox/store';
|
import type { AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
function useUserStream() {
|
function useUserStream() {
|
||||||
|
const { isLoggedIn } = useLoggedIn();
|
||||||
const statContext = useStatContext();
|
const statContext = useStatContext();
|
||||||
return useTimelineStream('home', 'user', refresh, null, { statContext });
|
|
||||||
|
return useTimelineStream(
|
||||||
|
'home',
|
||||||
|
'user',
|
||||||
|
refresh,
|
||||||
|
null,
|
||||||
|
{ statContext, enabled: isLoggedIn },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Refresh home timeline and notifications. */
|
/** Refresh home timeline and notifications. */
|
||||||
|
|
Loading…
Reference in a new issue