@@ -28,7 +28,6 @@ import type {
2828} from '../actions/postActivity' ;
2929import type { GlobalScopePonyfill } from '../types/GlobalScopePonyfill' ;
3030import type { WebChatActivity } from '../types/WebChatActivity' ;
31- import compose , { type ComposeFn } from './private/compose' ;
3231
3332type ActivitiesAction =
3433 | DeleteActivityAction
@@ -345,40 +344,31 @@ export default function createActivitiesReducer(
345344 ) ;
346345 }
347346
348- const updateOldSendStatusToSent : ComposeFn < WebChatActivity > = activity =>
349- updateIn (
350- activity ,
351- // `channelData.state` is being deprecated in favor of `channelData['webchat:send-status']`.
352- // Please refer to #4362 for details. Remove on or after 2024-07-31.
353- [ 'channelData' , 'state' ] ,
354- ( ) => SENT
355- ) ;
347+ // We will replace the outgoing activity with the version from the server
348+ let activity = patchActivity ( action . payload . activity , ponyfill ) ;
356349
357- const updateNewSendStatusToSent : ComposeFn < WebChatActivity > = activity =>
358- updateIn ( activity , [ 'channelData' , 'webchat:send-status' ] , ( ) => SENT ) ;
350+ activity = updateIn (
351+ activity ,
352+ // `channelData.state` is being deprecated in favor of `channelData['webchat:send-status']`.
353+ // Please refer to #4362 for details. Remove on or after 2024-07-31.
354+ [ 'channelData' , 'state' ] ,
355+ ( ) => SENT
356+ ) ;
359357
360- const updatePermanentId : ComposeFn < WebChatActivity > = activity =>
361- updateIn (
362- activity ,
363- [ 'channelData' , 'webchat:internal:id' ] ,
364- ( ) => existingActivity . channelData [ 'webchat:internal:id' ]
365- ) ;
358+ activity = updateIn ( activity , [ 'channelData' , 'webchat:send-status' ] , ( ) => SENT ) ;
366359
367- // Keep existing position.
368- const updatePosition : ComposeFn < WebChatActivity > = activity =>
369- updateIn (
370- activity ,
371- [ 'channelData' , 'webchat:internal:position' ] ,
372- ( ) => existingActivity . channelData [ 'webchat:internal:position' ]
373- ) ;
360+ activity = updateIn (
361+ activity ,
362+ [ 'channelData' , 'webchat:internal:id' ] ,
363+ ( ) => existingActivity . channelData [ 'webchat:internal:id' ]
364+ ) ;
374365
375- // We will replace the activity with the version from the server
376- const activity = compose < WebChatActivity > (
377- updateOldSendStatusToSent ,
378- updateNewSendStatusToSent ,
379- updatePermanentId ,
380- updatePosition
381- ) ( patchActivity ( action . payload . activity , ponyfill ) ) ;
366+ // Keep existing position.
367+ activity = updateIn (
368+ activity ,
369+ [ 'channelData' , 'webchat:internal:position' ] ,
370+ ( ) => existingActivity . channelData [ 'webchat:internal:position' ]
371+ ) ;
382372
383373 state = updateIn ( state , [ findByClientActivityID ( action . meta . clientActivityID ) ] , ( ) => activity ) ;
384374 }
0 commit comments