2024-04-25 02:45:28 +08:00
|
|
|
import React, { useRef } from 'react';
|
2023-11-14 02:36:49 +08:00
|
|
|
import EmojiRain from './component';
|
2024-04-25 02:45:28 +08:00
|
|
|
import { getEmojisToRain } from './queries';
|
2024-06-04 21:40:54 +08:00
|
|
|
import useDeduplicatedSubscription from '../../core/hooks/useDeduplicatedSubscription';
|
2023-11-14 02:36:49 +08:00
|
|
|
|
2024-04-25 02:45:28 +08:00
|
|
|
const EmojiRainContainer = () => {
|
|
|
|
const nowDate = useRef(new Date().toUTCString());
|
2023-11-14 02:36:49 +08:00
|
|
|
|
2024-04-25 02:45:28 +08:00
|
|
|
const {
|
|
|
|
data: emojisToRainData,
|
2024-06-04 21:40:54 +08:00
|
|
|
} = useDeduplicatedSubscription(getEmojisToRain, {
|
2024-04-25 02:45:28 +08:00
|
|
|
variables: {
|
|
|
|
initialCursor: nowDate.current,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const emojisArray = emojisToRainData?.user_reaction_stream || [];
|
|
|
|
|
|
|
|
const reactions = emojisArray.length === 0 ? []
|
|
|
|
: emojisArray.map((reaction) => ({
|
|
|
|
reaction: reaction.reactionEmoji,
|
|
|
|
creationDate: new Date(reaction.createdAt),
|
|
|
|
}));
|
|
|
|
|
|
|
|
return <EmojiRain reactions={reactions} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EmojiRainContainer;
|