diff --git a/app/soapbox/api/hooks/streaming/useDirectStream.ts b/app/soapbox/api/hooks/streaming/useDirectStream.ts index e97fc8860..9d3b47853 100644 --- a/app/soapbox/api/hooks/streaming/useDirectStream.ts +++ b/app/soapbox/api/hooks/streaming/useDirectStream.ts @@ -1,7 +1,17 @@ +import { useLoggedIn } from 'soapbox/hooks'; + import { useTimelineStream } from './useTimelineStream'; function useDirectStream() { - return useTimelineStream('direct', 'direct'); + const { isLoggedIn } = useLoggedIn(); + + return useTimelineStream( + 'direct', + 'direct', + null, + null, + { enabled: isLoggedIn }, + ); } export { useDirectStream }; \ No newline at end of file diff --git a/app/soapbox/api/hooks/streaming/useListStream.ts b/app/soapbox/api/hooks/streaming/useListStream.ts index f38b0209c..661bdce4f 100644 --- a/app/soapbox/api/hooks/streaming/useListStream.ts +++ b/app/soapbox/api/hooks/streaming/useListStream.ts @@ -1,9 +1,16 @@ +import { useLoggedIn } from 'soapbox/hooks'; + import { useTimelineStream } from './useTimelineStream'; function useListStream(listId: string) { + const { isLoggedIn } = useLoggedIn(); + return useTimelineStream( `list:${listId}`, `list&list=${listId}`, + null, + null, + { enabled: isLoggedIn }, ); } diff --git a/app/soapbox/api/hooks/streaming/useNostrStream.ts b/app/soapbox/api/hooks/streaming/useNostrStream.ts index 3e6ef707f..6748f95ea 100644 --- a/app/soapbox/api/hooks/streaming/useNostrStream.ts +++ b/app/soapbox/api/hooks/streaming/useNostrStream.ts @@ -1,11 +1,20 @@ -import { useFeatures } from 'soapbox/hooks'; +import { useFeatures, useLoggedIn } from 'soapbox/hooks'; import { useTimelineStream } from './useTimelineStream'; function useNostrStream() { const features = useFeatures(); - const enabled = features.nostrSign && Boolean(window.nostr); - return useTimelineStream('nostr', 'nostr', null, null, { enabled }); + const { isLoggedIn } = useLoggedIn(); + + return useTimelineStream( + 'nostr', + 'nostr', + null, + null, + { + enabled: isLoggedIn && features.nostrSign && Boolean(window.nostr), + }, + ); } export { useNostrStream }; \ No newline at end of file diff --git a/app/soapbox/api/hooks/streaming/useTimelineStream.ts b/app/soapbox/api/hooks/streaming/useTimelineStream.ts index a0dfb2ded..28998e090 100644 --- a/app/soapbox/api/hooks/streaming/useTimelineStream.ts +++ b/app/soapbox/api/hooks/streaming/useTimelineStream.ts @@ -17,7 +17,7 @@ function useTimelineStream(...args: Parameters) { const streamingUrl = instance.urls.get('streaming_api'); const connect = () => { - if (enabled && accessToken && streamingUrl && !stream.current) { + if (enabled && streamingUrl && !stream.current) { stream.current = dispatch(connectTimelineStream(...args)); } }; diff --git a/app/soapbox/api/hooks/streaming/useUserStream.ts b/app/soapbox/api/hooks/streaming/useUserStream.ts index 5e0bb9aed..cededf2aa 100644 --- a/app/soapbox/api/hooks/streaming/useUserStream.ts +++ b/app/soapbox/api/hooks/streaming/useUserStream.ts @@ -2,14 +2,23 @@ import { fetchAnnouncements } from 'soapbox/actions/announcements'; import { expandNotifications } from 'soapbox/actions/notifications'; import { expandHomeTimeline } from 'soapbox/actions/timelines'; import { useStatContext } from 'soapbox/contexts/stat-context'; +import { useLoggedIn } from 'soapbox/hooks'; import { useTimelineStream } from './useTimelineStream'; import type { AppDispatch } from 'soapbox/store'; function useUserStream() { + const { isLoggedIn } = useLoggedIn(); const statContext = useStatContext(); - return useTimelineStream('home', 'user', refresh, null, { statContext }); + + return useTimelineStream( + 'home', + 'user', + refresh, + null, + { statContext, enabled: isLoggedIn }, + ); } /** Refresh home timeline and notifications. */