pleroma/app/soapbox/features/chats/components/chat-widget/chat-widget.tsx

28 lines
613 B
TypeScript
Raw Normal View History

import React from 'react';
2022-10-03 06:14:45 -07:00
import { useHistory } from 'react-router-dom';
2022-08-16 10:38:17 -07:00
import { ChatProvider } from 'soapbox/contexts/chat-context';
import { useOwnAccount } from 'soapbox/hooks';
2022-08-16 10:38:17 -07:00
2022-10-17 05:34:19 -07:00
import ChatPane from '../chat-pane/chat-pane';
2022-08-16 10:38:17 -07:00
const ChatWidget = () => {
2022-09-22 09:55:29 -07:00
const account = useOwnAccount();
2022-10-03 06:14:45 -07:00
const history = useHistory();
2022-08-25 12:56:53 -07:00
2022-10-03 06:14:45 -07:00
const path = history.location.pathname;
const shouldHideWidget = Boolean(path.match(/^\/chats/));
if (!account?.chats_onboarded || shouldHideWidget) {
2022-09-22 09:55:29 -07:00
return null;
}
2022-08-16 10:38:17 -07:00
return (
<ChatProvider>
<ChatPane />
</ChatProvider>
);
};
export default ChatWidget;