pl-api: support bubble timeline streaming
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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.
|
||||
|
||||
11
packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts
Normal file
11
packages/pl-fe/src/api/hooks/streaming/use-bubble-stream.ts
Normal 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 };
|
||||
@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user