@amityco/ts-sdk-react-native
Version:
Amity Social Cloud Typescript SDK
17 lines (14 loc) • 829 B
text/typescript
import { getChannelMessagePreviewWithUser } from '~/messagePreview/utils';
import { constructChannelDynamicValue } from './constructChannelDynamicValue';
import { channelLinkedObject } from '~/utils/linkedObject/channelLinkedObject';
export const constructChannelObject = (channel: Amity.StaticInternalChannel): Amity.Channel => {
/**
* convert internal cache data to be public channel data
* 1. [getChannelMessagePreviewWithUser] add messagePreview >> Amity.InternalChannel -> Amity.InternalChannel
* 2. [constructChannelDynamicValue] construct getter value >> Amity.StaticInternalChannel -> Amity.Channel
* 3. [LinkedObject.channel] add markAsRead >> Amity.InternalChannel -> Amity.Channel
*/
return channelLinkedObject(
constructChannelDynamicValue(getChannelMessagePreviewWithUser(channel)),
);
};