UNPKG

@amityco/ts-sdk-react-native

Version:

Amity Social Cloud Typescript SDK

27 lines (25 loc) 938 B
import { pullFromCache } from '~/cache/api'; import { getLiveChat as _getLiveChat } from '~/streamRepository/internalApi/getLiveChat'; export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream => { return { ...stream, get moderation() { return pullFromCache<Amity.StreamModeration>(['streamModeration', 'get', stream.streamId]) ?.data; }, get post() { if (stream.referenceType !== 'post') return; return pullFromCache<Amity.InternalPost>(['post', 'get', stream.referenceId])?.data; }, get community() { if (stream.targetType !== 'community') return; return pullFromCache<Amity.Community>(['community', 'get', stream.targetId])?.data; }, get user() { return pullFromCache<Amity.User>(['user', 'get', stream.userId])?.data; }, getLiveChat: () => _getLiveChat(stream), isBanned: !stream.watcherUrl, watcherUrl: null, }; };