UNPKG

@amityco/ts-sdk-react-native

Version:

Amity Social Cloud Typescript SDK

52 lines (44 loc) 1.35 kB
import { getActiveClient } from '~/client/api'; import { ingestInCache } from '~/cache/api/ingestInCache'; import { LinkedObject } from '~/utils/linkedObject'; /* begin_public_function id: stream.update */ /** * * ```js * import { StreamRepository } from '@amityco/ts-sdk' * const updated = await StreamRepository.editStream(streamId, { title: 'foobar' }) * ``` * * Updates an {@link Amity.Stream} * * @param streamId The ID of the {@link Amity.Stream} to edit * @param patch The patch data to apply * @returns the updated {@link Amity.Stream} object * * @category Stream API * @async */ export const editStream = async ( streamId: Amity.Stream['streamId'], patch: Patch< Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled' >, ): Promise<Amity.Cached<Amity.Stream>> => { const client = getActiveClient(); client.log('stream/updateStream', streamId, patch); const { data } = await client.http.put<Amity.StreamPayload>( `/api/v3/video-streaming/${streamId}`, patch, ); const cachedAt = client.cache && Date.now(); if (client.cache) ingestInCache(data, { cachedAt }); const { videoStreamings } = data; return { data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)!), cachedAt, }; }; /* end_public_function */