Skip to content

Commit 61e3b00

Browse files
committed
added chatroute
1 parent 495e976 commit 61e3b00

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import Posts from 'screens/UserPortal/Posts/Posts';
3838
import Organizations from 'screens/UserPortal/Organizations/Organizations';
3939
import People from 'screens/UserPortal/People/People';
4040
import Settings from 'screens/UserPortal/Settings/Settings';
41-
// import Chat from 'screens/UserPortal/Chat/Chat';
41+
import Chat from 'screens/UserPortal/Chat/Chat';
4242
import { useQuery } from '@apollo/client';
4343
import { CHECK_AUTH } from 'GraphQl/Queries/Queries';
4444
import Advertisements from 'components/Advertisements/Advertisements';
@@ -191,6 +191,7 @@ function app(): JSX.Element {
191191
<Route element={<SecuredRouteForUser />}>
192192
<Route path="/user/organizations" element={<Organizations />} />
193193
<Route path="/user/settings" element={<Settings />} />
194+
<Route path="/user/chat/:orgId" element={<Chat />} />
194195
{/* <Route path="/user/chat" element={<Chat />} /> */}
195196
<Route element={<UserScreen />}>
196197
<Route path="/user/organizations" element={<Organizations />} />

src/screens/UserPortal/Chat/Chat.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,6 @@ export default function chat(): JSX.Element {
111111
const { getItem } = useLocalStorage();
112112
const userId = getItem('userId');
113113

114-
React.useEffect(() => {
115-
if (filterType === 'all') {
116-
chatsListRefetch();
117-
if (chatsListData && chatsListData.chatsByUserId) {
118-
setChats(chatsListData.chatsByUserId);
119-
}
120-
} else if (filterType === 'unread') {
121-
unreadChatListRefetch();
122-
if (unreadChatListData && unreadChatListData.getUnreadChatsByUserId) {
123-
setChats(unreadChatListData.getUnreadChatsByUserId);
124-
}
125-
} else if (filterType === 'group') {
126-
groupChatListRefetch();
127-
if (groupChatListData && groupChatListData.getGroupChatsByUserId) {
128-
setChats(groupChatListData.getGroupChatsByUserId);
129-
}
130-
}
131-
}, [filterType]);
132-
133114
const [createDirectChatModalisOpen, setCreateDirectChatModalisOpen] =
134115
useState(false);
135116

@@ -180,6 +161,25 @@ export default function chat(): JSX.Element {
180161
});
181162
}, [selectedContact]);
182163

164+
React.useEffect(() => {
165+
if (filterType === 'all') {
166+
chatsListRefetch();
167+
if (chatsListData && chatsListData.chatsByUserId) {
168+
setChats(chatsListData.chatsByUserId);
169+
}
170+
} else if (filterType === 'unread') {
171+
unreadChatListRefetch();
172+
if (unreadChatListData && unreadChatListData.getUnreadChatsByUserId) {
173+
setChats(unreadChatListData.getUnreadChatsByUserId);
174+
}
175+
} else if (filterType === 'group') {
176+
groupChatListRefetch();
177+
if (groupChatListData && groupChatListData.getGroupChatsByUserId) {
178+
setChats(groupChatListData.getGroupChatsByUserId);
179+
}
180+
}
181+
}, [filterType]);
182+
183183
React.useEffect(() => {
184184
if (chatsListData && chatsListData?.chatsByUserId.length) {
185185
setChats(chatsListData.chatsByUserId);

0 commit comments

Comments
 (0)