@@ -31,30 +31,28 @@ const recentChatDataSlice = createSlice({
3131 state . recentChats = updatedChats ;
3232 } ,
3333 addRecentChatItem ( state , action ) {
34- const { userJid, newIndex = 0 , archiveSetting, publisherId, timestamp } = action . payload ;
34+ const { userJid, newIndex = 0 , archiveSetting, publisherId } = action . payload ;
3535 const index = state . recentChats . findIndex ( item => item ?. userJid === userJid ) ;
3636
3737 if ( index !== - 1 ) {
3838 const existingChat = state . recentChats [ index ] ;
39- if ( timestamp > existingChat . timestamp ) {
40- const updatedChat = {
41- ...existingChat ,
42- ...action . payload ,
43- deleteStatus : 0 ,
44- recallStatus : 0 ,
45- archiveStatus : archiveSetting === 0 ? archiveSetting : existingChat . archiveStatus ,
46- } ;
47- if ( userJid !== getCurrentChatUser ( ) && ! isLocalUser ( publisherId ) ) {
48- updatedChat . unreadCount += 1 ;
49- updatedChat . isUnread = 1 ;
50- }
39+ const updatedChat = {
40+ ...existingChat ,
41+ ...action . payload ,
42+ deleteStatus : 0 ,
43+ recallStatus : 0 ,
44+ archiveStatus : archiveSetting === 0 ? archiveSetting : existingChat . archiveStatus ,
45+ } ;
46+ if ( userJid !== getCurrentChatUser ( ) && ! isLocalUser ( publisherId ) ) {
47+ updatedChat . unreadCount += 1 ;
48+ updatedChat . isUnread = 1 ;
49+ }
5150
52- const newData = [ ...state . recentChats ] ;
53- newData . splice ( index , 1 ) ; // Remove the old entry
54- newData . splice ( newIndex , 0 , updatedChat ) ; // Insert the updated entry
51+ const newData = [ ...state . recentChats ] ;
52+ newData . splice ( index , 1 ) ; // Remove the old entry
53+ newData . splice ( newIndex , 0 , updatedChat ) ; // Insert the updated entry
5554
56- state . recentChats = newData ;
57- }
55+ state . recentChats = newData ;
5856 } else if ( action . payload ) {
5957 // If the item is not found, add the new message at the top
6058 const newChat = {
0 commit comments