@@ -111,25 +111,6 @@ export default function chat(): JSX.Element {
111
111
const { getItem } = useLocalStorage ( ) ;
112
112
const userId = getItem ( 'userId' ) ;
113
113
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
-
133
114
const [ createDirectChatModalisOpen , setCreateDirectChatModalisOpen ] =
134
115
useState ( false ) ;
135
116
@@ -180,6 +161,25 @@ export default function chat(): JSX.Element {
180
161
} ) ;
181
162
} , [ selectedContact ] ) ;
182
163
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
+
183
183
React . useEffect ( ( ) => {
184
184
if ( chatsListData && chatsListData ?. chatsByUserId . length ) {
185
185
setChats ( chatsListData . chatsByUserId ) ;
0 commit comments