File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed
src/screens/UserPortal/Chat Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -162,29 +162,25 @@ export default function chat(): JSX.Element {
162
162
} , [ selectedContact ] ) ;
163
163
164
164
React . useEffect ( ( ) => {
165
- let isMounted = true ;
166
- if ( filterType === 'all' ) {
167
- chatsListRefetch ( ) . then ( ( ) => {
168
- if ( isMounted && chatsListData ? .chatsByUserId ) {
165
+ async function getChats ( ) : Promise < void > {
166
+ if ( filterType === 'all' ) {
167
+ await chatsListRefetch ( ) ;
168
+ if ( chatsListData && chatsListData . chatsByUserId ) {
169
169
setChats ( chatsListData . chatsByUserId ) ;
170
170
}
171
- } ) ;
172
- } else if ( filterType === 'unread' ) {
173
- unreadChatListRefetch ( ) . then ( ( ) => {
174
- if ( isMounted && unreadChatListData ?. getUnreadChatsByUserId ) {
171
+ } else if ( filterType === 'unread' ) {
172
+ await unreadChatListRefetch ( ) ;
173
+ if ( unreadChatListData && unreadChatListData . getUnreadChatsByUserId ) {
175
174
setChats ( unreadChatListData . getUnreadChatsByUserId ) ;
176
175
}
177
- } ) ;
178
- } else if ( filterType === 'group' ) {
179
- groupChatListRefetch ( ) . then ( ( ) => {
180
- if ( isMounted && groupChatListData ?. getGroupChatsByUserId ) {
176
+ } else if ( filterType === 'group' ) {
177
+ await groupChatListRefetch ( ) ;
178
+ if ( groupChatListData && groupChatListData . getGroupChatsByUserId ) {
181
179
setChats ( groupChatListData . getGroupChatsByUserId ) ;
182
180
}
183
- } ) ;
181
+ }
184
182
}
185
- return ( ) => {
186
- isMounted = false ;
187
- } ;
183
+ getChats ( ) ;
188
184
} , [ filterType ] ) ;
189
185
190
186
React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments