pl-api: support bubble timeline streaming

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-04-17 17:46:30 +02:00
parent 495076e026
commit 32ff4b1e59
3 changed files with 20 additions and 1 deletions

View File

@ -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.

View File

@ -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 };

View File

@ -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]);