From 32ff4b1e5924f2851878e3d9b1574dde03b773a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Thu, 17 Apr 2025 17:46:30 +0200 Subject: [PATCH] pl-api: support bubble timeline streaming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicole Mikołajczyk --- packages/pl-api/lib/features.ts | 7 ++++++- .../src/api/hooks/streaming/use-bubble-stream.ts | 11 +++++++++++ packages/pl-fe/src/features/bubble-timeline/index.tsx | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 518d40ef1..2d19b18f0 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -414,7 +414,12 @@ const getFeatures = (instance: Instance) => { * Can display a timeline of statuses from instances selected by instance admin. * @see GET /api/v1/timelines/bubble */ - bubbleTimeline: instance.api_versions['bubble_timeline.pleroma.pl-api'] >= 1, + bubbleTimeline: any([ + instance.api_versions['bubble_timeline.pleroma.pl-api'] >= 1, + v.software === ICESHRIMP_NET, + ]), + + bubbleTimelineStreaming: v.software === ICESHRIMP_NET, /** * Pleroma chats API. diff --git a/packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts b/packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts new file mode 100644 index 000000000..7415abc46 --- /dev/null +++ b/packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts @@ -0,0 +1,11 @@ +import { useTimelineStream } from './use-timeline-stream'; + +interface UseBubbleStreamOpts { + onlyMedia?: boolean; + enabled?: boolean; +} + +const useBubbleStream = ({ onlyMedia, enabled }: UseBubbleStreamOpts = {}) => + useTimelineStream(`bubble${onlyMedia ? ':media' : ''}`, {}, enabled); + +export { useBubbleStream }; diff --git a/packages/pl-fe/src/features/bubble-timeline/index.tsx b/packages/pl-fe/src/features/bubble-timeline/index.tsx index 74b63b168..e2babe414 100644 --- a/packages/pl-fe/src/features/bubble-timeline/index.tsx +++ b/packages/pl-fe/src/features/bubble-timeline/index.tsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { fetchBubbleTimeline } from 'pl-fe/actions/timelines'; +import { useBubbleStream } from 'pl-fe/api/hooks/streaming/use-bubble-stream'; import PullToRefresh from 'pl-fe/components/pull-to-refresh'; import Column from 'pl-fe/components/ui/column'; import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; @@ -32,6 +33,8 @@ const BubbleTimeline = () => { const handleRefresh = () => dispatch(fetchBubbleTimeline({ onlyMedia }, true)); + useBubbleStream({ onlyMedia }); + useEffect(() => { dispatch(fetchBubbleTimeline({ onlyMedia })); }, [onlyMedia]);