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;