+
+ {channels.map(c => {
+ const otherUserId = (c as ChannelTypes.DM).userIds
+ .find(id => id !== selfUser.id);
+ const otherUser = users.find(u => u.id === otherUserId);
+ if (!otherUser) return null;
+
+ return (
+
+
+
+ );
+ })}
+
+
+ );
+}
+
+export default DMList;
\ No newline at end of file
diff --git a/frontend/src/components/pages/dm-page.tsx b/frontend/src/components/pages/dm-page.tsx
new file mode 100644
index 00000000..c4d0921e
--- /dev/null
+++ b/frontend/src/components/pages/dm-page.tsx
@@ -0,0 +1,58 @@
+import { useDispatch, useSelector } from 'react-redux';
+import AppNavbar from '../navigation/app-navbar';
+import Sidebar from '../navigation/sidebar/sidebar';
+import { Redirect, useParams } from 'react-router-dom';
+import { actions as uiActions } from '../../store/ui';
+import TextBasedChannel from '../channel/text-based-channel';
+import { useEffect } from 'react';
+import PageWrapper from './page-wrapper';
+import { getDMChannel, createDM } from '../../store/channels';
+import WSListener from '../ws-listener';
+import DMList from '../navigation/sidebar/dm-list';
+
+const DMPage: React.FunctionComponent = () => {
+ const { channelId }: any = useParams();
+ const dispatch = useDispatch();
+ const channel = useSelector(getDMChannel(channelId));
+ const users = useSelector((s: Store.AppState) => s.entities.users);
+ const selfUser = useSelector((s: Store.AppState) => s.auth.user)!;
+ const ui = useSelector((s: Store.AppState) => s.ui);
+
+ useEffect(() => {
+ if (!channel && channelId) {
+ const otherUser = users.find(u => u.id === channelId);
+ if (otherUser) {
+ dispatch(createDM(otherUser.id));
+ }
+ }
+ dispatch(uiActions.pageSwitched({ channel }));
+ }, [channel, channelId]);
+
+ if (!channel && !channelId)
+ return