diff --git a/package.json b/package.json index eda8c4d7670..387e1c61806 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start:prod": "NODE_ENV=production node build/server.js" }, "dependencies": { - "@ecency/ns-query": "^1.0.4", + "@ecency/ns-query": "^1.0.5", "@ecency/render-helper": "^2.2.29", "@ecency/render-helper-amp": "^1.1.0", "@emoji-mart/data": "^1.1.2", diff --git a/src/common/features/chats/components/chat-input.tsx b/src/common/features/chats/components/chat-input.tsx index cc83d1794f1..6a4e50e837b 100644 --- a/src/common/features/chats/components/chat-input.tsx +++ b/src/common/features/chats/components/chat-input.tsx @@ -22,11 +22,10 @@ import { Channel, ChatContext, DirectContact, - getUserChatPublicKey, useChannelsQuery, + useGetPublicKeysQuery, useSendMessage } from "@ecency/ns-query"; -import { useGetAccountFullQuery } from "../../../api/queries"; import Tooltip from "../../../components/tooltip"; import { ChatInputFiles } from "./chat-input-files"; import Gallery from "../../../components/gallery"; @@ -52,7 +51,9 @@ export default function ChatInput({ currentChannel, currentContact }: Props) { const [showGifPicker, setShowGifPicker] = useState(false); const [showGallery, setShowGallery] = useState(false); - const { data: contactData } = useGetAccountFullQuery(currentContact?.name); + const { data: contactKeys, isLoading: isContactKeysLoading } = useGetPublicKeysQuery( + currentContact?.name + ); const { mutateAsync: sendMessage, isLoading: isSendMessageLoading } = useSendMessage( currentChannel, currentContact, @@ -68,9 +69,10 @@ export default function ChatInput({ currentChannel, currentContact }: Props) { () => isCurrentUser && !receiverPubKey, [isCurrentUser, receiverPubKey] ); + const isJoined = useMemo(() => (contactKeys ? contactKeys.pubkey : false), [contactKeys]); const isReadOnly = useMemo( - () => (contactData ? currentContact?.pubkey !== getUserChatPublicKey(contactData) : false), - [contactData, currentContact] + () => (contactKeys && isJoined ? currentContact?.pubkey !== contactKeys.pubkey : false), + [contactKeys, currentContact, isJoined] ); const isFilesUploading = useMemo( () => (files.length > 0 ? files.length !== uploadedFileLinks.length : false), diff --git a/src/common/features/chats/components/chat-popup/chat-direct-contact-or-channel-item.tsx b/src/common/features/chats/components/chat-popup/chat-direct-contact-or-channel-item.tsx deleted file mode 100644 index e0470ee3402..00000000000 --- a/src/common/features/chats/components/chat-popup/chat-direct-contact-or-channel-item.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { useMemo } from "react"; -import UserAvatar from "../../../../components/user-avatar"; -import { - Channel, - DirectContact, - getUserChatPublicKey, - isCommunity, - useLastMessageQuery -} from "@ecency/ns-query"; -import { useCommunityCache } from "../../../../core"; -import { classNameObject } from "../../../../helper/class-name-object"; -import { useGetAccountFullQuery } from "../../../../api/queries"; -import { _t } from "../../../../i18n"; -import Tooltip from "../../../../components/tooltip"; -import { Button } from "@ui/button"; -import { informationOutlineSvg } from "../../../../img/svg"; - -interface Props { - username: string; - contact?: DirectContact; - channel?: Channel; - userClicked: (username: string) => void; -} - -export function ChatDirectContactOrChannelItem({ contact, channel, username, userClicked }: Props) { - const lastMessage = useLastMessageQuery(contact, channel); - const { data: community } = useCommunityCache(channel?.communityName); - - const { data: contactData } = useGetAccountFullQuery(contact?.name); - - const isJoined = useMemo( - () => (contactData ? !!getUserChatPublicKey(contactData) : true), - [contactData] - ); - const isReadOnly = useMemo( - () => (contactData && isJoined ? contact?.pubkey !== getUserChatPublicKey(contactData) : false), - [contactData, contact, isJoined] - ); - return ( -
{lastMessage?.content}
-