UNPKG

@amityco/ts-sdk-react-native

Version:

Amity Social Cloud Typescript SDK

82 lines (65 loc) 2.06 kB
export * from './idResolvers'; export * from './identifyModel'; /** * A map of v3 response keys to a store name. * @hidden */ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = { users: 'user', files: 'file', roles: 'role', stories: 'story', storyTargets: 'storyTarget', channels: 'channel', messageFeeds: 'subChannel', channelUsers: 'channelUsers', messages: 'message', messagePreviewChannel: 'messagePreviewChannel', messagePreviewSubChannel: 'messagePreviewSubChannel', channelUnreadInfo: 'channelUnreadInfo', subChannelUnreadInfo: 'subChannelUnreadInfo', userEntityMarkers: 'channelMarker', userFeedMarkers: 'subChannelMarker', contentMarkers: 'messageMarker', feedMarkers: 'feedMarker', userMarkers: 'userMarker', communities: 'community', categories: 'category', communityUsers: 'communityUsers', posts: 'post', postChildren: 'post', comments: 'comment', commentChildren: 'comment', polls: 'poll', reactors: 'reactor', reactions: 'reaction', videoStreamings: 'stream', videoStreamingChildren: 'stream', videoStreamModerations: 'streamModeration', follows: 'follow', followCounts: 'followCount', feeds: 'feed', ads: 'ad', advertisers: 'advertiser', pinTargets: 'pinTarget', pins: 'pin', notificationTrayItems: 'notificationTrayItem', invitations: 'invitation', joinRequests: 'joinRequest', }; /** hidden */ export const isOutdated = <T extends Amity.UpdatedAt>(prevData: T, nextData: T): boolean => { // Check if the new value is outdated. if ('updatedAt' in nextData && 'updatedAt' in prevData) { return new Date(nextData.updatedAt!) < new Date(prevData.updatedAt!); } return false; }; /** hidden */ export function getFutureDate(date: string | undefined = new Date().toISOString()): string { return new Date(new Date(date).getTime() + 1).toISOString(); } /** hidden */ export function getPastDate(date: string | undefined = new Date().toISOString()): string { return new Date(new Date(date).getTime() - 1).toISOString(); }