Fix errant fetches to the silence endpoint
This commit is contained in:
parent
641bf1268d
commit
0003b7323a
3 changed files with 18 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { blockAccount } from 'soapbox/actions/accounts';
|
import { blockAccount } from 'soapbox/actions/accounts';
|
||||||
|
@ -33,7 +33,7 @@ const ChatPageMain = () => {
|
||||||
const account = useOwnAccount();
|
const account = useOwnAccount();
|
||||||
|
|
||||||
const { chat, setChat } = useChatContext();
|
const { chat, setChat } = useChatContext();
|
||||||
const { isSilenced, handleSilence } = useChatSilence(chat);
|
const { isSilenced, handleSilence, fetchChatSilence } = useChatSilence(chat);
|
||||||
const { deleteChat } = useChat(chat?.id as string);
|
const { deleteChat } = useChat(chat?.id as string);
|
||||||
|
|
||||||
const handleBlockUser = () => {
|
const handleBlockUser = () => {
|
||||||
|
@ -58,6 +58,12 @@ const ChatPageMain = () => {
|
||||||
|
|
||||||
const handleReportChat = () => dispatch(initReport(chat?.account as any));
|
const handleReportChat = () => dispatch(initReport(chat?.account as any));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (chat?.id) {
|
||||||
|
fetchChatSilence();
|
||||||
|
}
|
||||||
|
}, [chat?.id]);
|
||||||
|
|
||||||
if (!chat && !account?.chats_onboarded) {
|
if (!chat && !account?.chats_onboarded) {
|
||||||
return (
|
return (
|
||||||
<Welcome />
|
<Welcome />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { blockAccount } from 'soapbox/actions/accounts';
|
import { blockAccount } from 'soapbox/actions/accounts';
|
||||||
|
@ -30,7 +30,7 @@ const ChatSettings = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const { chat, setEditing, toggleChatPane } = useChatContext();
|
const { chat, setEditing, toggleChatPane } = useChatContext();
|
||||||
const { isSilenced, handleSilence } = useChatSilence(chat);
|
const { isSilenced, handleSilence, fetchChatSilence } = useChatSilence(chat);
|
||||||
|
|
||||||
const { deleteChat } = useChat(chat?.id as string);
|
const { deleteChat } = useChat(chat?.id as string);
|
||||||
|
|
||||||
|
@ -63,6 +63,12 @@ const ChatSettings = () => {
|
||||||
|
|
||||||
const handleReportChat = () => dispatch(initReport(chat?.account as any));
|
const handleReportChat = () => dispatch(initReport(chat?.account as any));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (chat?.id) {
|
||||||
|
fetchChatSilence();
|
||||||
|
}
|
||||||
|
}, [chat?.id]);
|
||||||
|
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import { useEffect, useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { fetchRelationships } from 'soapbox/actions/accounts';
|
import { fetchRelationships } from 'soapbox/actions/accounts';
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
|
@ -255,13 +255,7 @@ const useChatSilence = (chat: IChat | null) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
return { isSilenced, handleSilence, fetchChatSilence };
|
||||||
if (chat?.id) {
|
|
||||||
fetchChatSilence();
|
|
||||||
}
|
|
||||||
}, [chat?.id]);
|
|
||||||
|
|
||||||
return { isSilenced, handleSilence };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { useChat, useChats, useChatMessages, useChatSilences, useChatSilence };
|
export { useChat, useChats, useChatMessages, useChatSilences, useChatSilence };
|
||||||
|
|
Loading…
Reference in a new issue