File tree Expand file tree Collapse file tree
libs/store/src/lib/channels Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,13 +221,27 @@ export const channelMetaSlice = createSlice({
221221 updateDmLastSentMessage : ( state , action : PayloadAction < { channelId : string ; message : ChannelMessage } > ) => {
222222 const { channelId, message } = action . payload ;
223223 const updatedMessage = mapMessageToConversation ( message ) ;
224- dmMetaAdapter . updateOne ( state . dmEntities , {
225- id : channelId ,
226- changes : {
224+
225+ const checkExist = state . dmEntities ?. entities [ channelId ] ;
226+ if ( checkExist ) {
227+ dmMetaAdapter . updateOne ( state . dmEntities , {
228+ id : channelId ,
229+ changes : {
230+ last_sent_message : updatedMessage ,
231+ lastSentTimestamp : updatedMessage ?. timestamp_seconds || Date . now ( ) / 1000
232+ }
233+ } ) ;
234+ } else {
235+ dmMetaAdapter . addOne ( state . dmEntities , {
236+ id : channelId ,
237+ clanId : message . clan_id || '' ,
238+ isMute : false ,
239+ senderId : message . sender_id ,
240+ lastSeenTimestamp : updatedMessage ?. timestamp_seconds || Date . now ( ) / 1000 - 1 ,
227241 last_sent_message : updatedMessage ,
228242 lastSentTimestamp : updatedMessage ?. timestamp_seconds || Date . now ( ) / 1000
229- }
230- } ) ;
243+ } ) ;
244+ }
231245 } ,
232246 dmMetaAdd : ( state , action : PayloadAction < { channelId : string ; clanId : string } > ) => {
233247 const { channelId, clanId } = action . payload ;
You can’t perform that action at this time.
0 commit comments