From e8b7fd8db8be5d2e13fd4c22887e959364a2dd79 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 28 Sep 2022 13:37:56 -0500 Subject: [PATCH] Route /chats/:chatId to ChatPage component, cleanup UI imports, nuke ChatRoom (he cry) --- app/soapbox/features/chats/chat-room.tsx | 55 ------------------- app/soapbox/features/ui/index.tsx | 15 +---- .../features/ui/util/async-components.ts | 4 -- 3 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 app/soapbox/features/chats/chat-room.tsx diff --git a/app/soapbox/features/chats/chat-room.tsx b/app/soapbox/features/chats/chat-room.tsx deleted file mode 100644 index d7cc1cfe73..0000000000 --- a/app/soapbox/features/chats/chat-room.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { Map as ImmutableMap } from 'immutable'; -import React, { useEffect } from 'react'; - -import { fetchChat, markChatRead } from 'soapbox/actions/chats'; -import { Column } from 'soapbox/components/ui'; -import { useAppSelector, useAppDispatch } from 'soapbox/hooks'; -import { makeGetChat } from 'soapbox/selectors'; -import { getAcct } from 'soapbox/utils/accounts'; -import { displayFqn as getDisplayFqn } from 'soapbox/utils/state'; - -import Chat from './components/chat'; - -const getChat = makeGetChat(); - -interface IChatRoom { - params: { - chatId: string, - } -} - -/** Fullscreen chat UI. */ -const ChatRoom: React.FC = ({ params }) => { - const dispatch = useAppDispatch(); - const displayFqn = useAppSelector(getDisplayFqn); - - const chat = useAppSelector(state => { - const chat = state.chats.items.get(params.chatId, ImmutableMap()).toJS() as any; - return getChat(state, chat); - }); - - const markRead = () => { - if (!chat) return; - dispatch(markChatRead(chat.id)); - }; - - useEffect(() => { - dispatch(fetchChat(params.chatId)); - markRead(); - }, [params.chatId]); - - // If this component is loaded at all, we can instantly mark new messages as read. - useEffect(() => { - markRead(); - }, [chat?.unread]); - - if (!chat) return null; - - return ( - - - - ); -}; - -export default ChatRoom; diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index 2b3b07feb4..6b2405ef62 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -28,15 +28,14 @@ import { useAppDispatch, useAppSelector, useOwnAccount, useSoapboxConfig, useFea import AdminPage from 'soapbox/pages/admin_page'; import ChatsPage from 'soapbox/pages/chats-page'; import DefaultPage from 'soapbox/pages/default_page'; -// import GroupsPage from 'soapbox/pages/groups_page'; -// import GroupPage from 'soapbox/pages/group_page'; import HomePage from 'soapbox/pages/home_page'; import ProfilePage from 'soapbox/pages/profile_page'; import RemoteInstancePage from 'soapbox/pages/remote_instance_page'; import StatusPage from 'soapbox/pages/status_page'; import { getAccessToken, getVapidKey } from 'soapbox/utils/auth'; import { isStandalone } from 'soapbox/utils/state'; -// import GroupSidebarPanel from '../groups/sidebar_panel'; + +import { StatProvider } from '../../contexts/stat-context'; import BackgroundShapes from './components/background_shapes'; import Navbar from './components/navbar'; @@ -64,15 +63,9 @@ import { Filters, PinnedStatuses, Search, - // Groups, - // GroupTimeline, ListTimeline, Lists, Bookmarks, - // GroupMembers, - // GroupRemovedAccounts, - // GroupCreate, - // GroupEdit, Settings, MediaDisplay, EditProfile, @@ -86,7 +79,6 @@ import { // Backups, MfaForm, ChatIndex, - ChatRoom, ChatWidget, ServerInfo, Dashboard, @@ -118,7 +110,6 @@ import { WrappedRoute } from './util/react_router_helpers'; // Dummy import, to make sure that ends up in the application bundle. // Without this it ends up in ~8 very commonly used bundles. import 'soapbox/components/status'; -import { StatProvider } from '../../contexts/stat-context'; const EmptyPage = HomePage; @@ -264,7 +255,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => { {features.profileDirectory && } {features.chats && } - {features.chats && } + {features.chats && } diff --git a/app/soapbox/features/ui/util/async-components.ts b/app/soapbox/features/ui/util/async-components.ts index eb77a37e8b..5fce9cf6fb 100644 --- a/app/soapbox/features/ui/util/async-components.ts +++ b/app/soapbox/features/ui/util/async-components.ts @@ -294,10 +294,6 @@ export function ChatIndex() { return import(/* webpackChunkName: "features/chats" */'../../chats'); } -export function ChatRoom() { - return import(/* webpackChunkName: "features/chats/chat_room" */'../../chats/chat-room'); -} - export function ChatWidget() { return import(/* webpackChunkName: "features/chats/components/chat-widget" */'../../chats/components/chat-widget'); }