Make sure relationship is fetched in Chat Main Page

revert-fa4bd20d
Chewbacca 2022-11-03 16:54:18 -04:00
rodzic 4767f4fd8c
commit bc65331cbb
2 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -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>(ChatWidgetScreens.INBOX);
const [currentChatId, setCurrentChatId] = useState<null | string>(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;

Wyświetl plik

@ -187,6 +187,7 @@ const useChat = (chatId?: string) => {
if (chatId) {
const { data } = await api.get<IChat>(`/api/v1/pleroma/chats/${chatId}`);
dispatch(fetchRelationships([data.account.id]));
dispatch(importFetchedAccount(data.account));
return data;