From bc65331cbb9f869fa9914919896b569ab347628a Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Thu, 3 Nov 2022 16:54:18 -0400 Subject: [PATCH] Make sure relationship is fetched in Chat Main Page --- app/soapbox/contexts/chat-context.tsx | 5 +++-- app/soapbox/queries/chats.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/soapbox/contexts/chat-context.tsx b/app/soapbox/contexts/chat-context.tsx index cfd281b41..35c3f9cf4 100644 --- a/app/soapbox/contexts/chat-context.tsx +++ b/app/soapbox/contexts/chat-context.tsx @@ -1,6 +1,6 @@ import React, { createContext, useContext, useMemo, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { useHistory } from 'react-router-dom'; +import { useHistory, useParams } from 'react-router-dom'; import { toggleMainWindow } from 'soapbox/actions/chats'; import { useOwnAccount, useSettings } from 'soapbox/hooks'; @@ -28,11 +28,12 @@ const ChatProvider: React.FC = ({ children }) => { const path = history.location.pathname; const isUsingMainChatPage = Boolean(path.match(/^\/chats/)); + const { chatId } = useParams<{ chatId: string }>(); const [screen, setScreen] = useState(ChatWidgetScreens.INBOX); const [currentChatId, setCurrentChatId] = useState(null); - const { data: chat } = useChat(currentChatId as string); + const { data: chat } = useChat(currentChatId || chatId as string); const mainWindowState = settings.getIn(['chats', 'mainWindow']) as WindowState; const needsAcceptance = !chat?.accepted && chat?.created_by_account !== account?.id; diff --git a/app/soapbox/queries/chats.ts b/app/soapbox/queries/chats.ts index e6556c14b..0423b29b6 100644 --- a/app/soapbox/queries/chats.ts +++ b/app/soapbox/queries/chats.ts @@ -187,6 +187,7 @@ const useChat = (chatId?: string) => { if (chatId) { const { data } = await api.get(`/api/v1/pleroma/chats/${chatId}`); + dispatch(fetchRelationships([data.account.id])); dispatch(importFetchedAccount(data.account)); return data;