UNPKG

@sendbird/uikit-utils

Version:

A collection of utility functions and constants for building chat UI components with Sendbird UIKit.

20 lines 1.1 kB
import { getMessagePreviewBody, getMessagePreviewTime } from './common'; export const getGroupChannelTitle = (currentUserId, channel, EMPTY_USERNAME = '(No name)', NO_MEMBERS = '(No members)', DEFAULT_CHANNEL_NAME = 'Group Channel') => { if (channel.name !== DEFAULT_CHANNEL_NAME && channel.name !== '') return channel.name; if (channel.memberCount === 1) return NO_MEMBERS; return channel.members.filter(({ userId }) => userId !== currentUserId).map(({ nickname }) => nickname || EMPTY_USERNAME).join(', '); }; export const getGroupChannelPreviewTime = (channel, locale) => { var _channel$lastMessage; return getMessagePreviewTime(((_channel$lastMessage = channel.lastMessage) === null || _channel$lastMessage === void 0 ? void 0 : _channel$lastMessage.createdAt) || channel.joinedAt * 1000 || channel.createdAt, locale); }; export const getGroupChannelLastMessage = (channel, EMPTY_MESSAGE = '') => { const message = channel.lastMessage; if (!message) return EMPTY_MESSAGE; return getMessagePreviewBody(message, EMPTY_MESSAGE); }; //# sourceMappingURL=groupChannel.js.map