From c5c47e9bfce96d488be47436a619839945f74101 Mon Sep 17 00:00:00 2001 From: swtmply Date: Fri, 19 May 2023 00:14:28 +0800 Subject: [PATCH] IO-2208 remove unused variables and imports --- .../chat-popup/chat-popup.component.jsx | 54 ++----------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/client/src/components/chat-popup/chat-popup.component.jsx b/client/src/components/chat-popup/chat-popup.component.jsx index 5ac4baec1..899fd3058 100644 --- a/client/src/components/chat-popup/chat-popup.component.jsx +++ b/client/src/components/chat-popup/chat-popup.component.jsx @@ -4,7 +4,7 @@ import { ShrinkOutlined, SyncOutlined, } from "@ant-design/icons"; -import { useLazyQuery, useQuery, useSubscription } from "@apollo/client"; +import { useLazyQuery, useSubscription } from "@apollo/client"; import { Badge, Card, Col, Row, Space, Tag, Tooltip, Typography } from "antd"; import React, { useCallback, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -46,17 +46,9 @@ export function ChatPopupComponent({ UNREAD_CONVERSATION_COUNT_SUBSCRIPTION ); - // const { data: unreadData, refetch: unreadRefetch } = useQuery( - // UNREAD_CONVERSATION_COUNT, - // { - // fetchPolicy: "network-only", - // nextFetchPolicy: "network-only", - // } - // ); - const [ getConversations, - { loading, data, called, fetchMore, subscribeToMore }, + { loading, data, called, refetch, fetchMore, subscribeToMore }, ] = useLazyQuery(CONVERSATION_LIST_QUERY, { fetchPolicy: "cache-and-network", nextFetchPolicy: "cache-first", @@ -91,44 +83,6 @@ export function ChatPopupComponent({ }); }, [data, fetchMore]); - const subscribeToMoreConversations = useCallback( - () => - subscribeToMore({ - document: CONVERSATION_LIST_SUBSCRIPTION, - variables: { offset: 0 }, - updateQuery: (prev, { subscriptionData }) => { - console.log("Hello"); - if ( - !subscriptionData.data || - subscriptionData.data.conversations.length === 0 - ) - return prev; - - let conversations = prev.conversations; - const newConversations = subscriptionData.data.conversations; - - for (const conversation of newConversations) { - const index = conversations.findIndex( - (prevConversation) => prevConversation.id === conversation.id - ); - - if (index !== -1) { - conversations.splice(index, 1); - conversations.unshift(conversation); - continue; - } - - conversation.unshift(conversation); - } - - return Object.assign({}, prev, { - conversations: conversations, - }); - }, - }), - [subscribeToMore] - ); - const unreadCount = unreadData?.messages_aggregate.aggregate.count || 0; return ( @@ -144,10 +98,10 @@ export function ChatPopupComponent({ - {/* refetch()} - /> */} + /> {pollInterval > 0 && ( {t("messaging.labels.nopush")} )}