RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/components/message/hooks/useSubscriptionFromMessageQuery.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { IMessage } from '@rocket.chat/core-typings';
import { useQuery } from '@tanstack/react-query';

import { useChat } from '../../../views/room/contexts/ChatContext';

export const useSubscriptionFromMessageQuery = (message: IMessage) => {
    const chat = useChat();

    return useQuery(['messages', message._id, 'subscription'], async () => {
        return chat?.data.getSubscriptionFromMessage(message) ?? null;
    });
};