TelegramPWA/src/global/helpers/reactions.ts
2022-05-30 15:40:11 +04:00

13 lines
513 B
TypeScript

import type { ApiMessage, ApiReactions } from '../../api/types';
import type { GlobalState } from '../types';
export function getMessageRecentReaction(message: Partial<ApiMessage>) {
return message.isOutgoing ? message.reactions?.recentReactions?.[0] : undefined;
}
export function checkIfHasUnreadReactions(global: GlobalState, reactions: ApiReactions) {
const { currentUserId } = global;
return reactions?.recentReactions?.some(
({ isUnread, userId }) => isUnread && userId !== currentUserId,
);
}