@@ -94,7 +94,8 @@ import {
94
94
setIsActionsLoading ,
95
95
setActionsList ,
96
96
setSnapshotImageActionList ,
97
- setUndoRedoActionList
97
+ setUndoRedoActionList ,
98
+ setPast
98
99
} from './actions' ;
99
100
import { api , METHOD } from '../../../js/utils/api' ;
100
101
import { base_url } from '../../components/routes/constants' ;
@@ -124,6 +125,7 @@ import {
124
125
setInspirationMoleculeDataList
125
126
} from '../../components/datasets/redux/actions' ;
126
127
import { selectVectorAndResetCompounds } from '../../../js/reducers/selection/dispatchActions' ;
128
+ import { ActionCreators as UndoActionCreators } from '../../undoredo/actions'
127
129
128
130
export const addCurrentActionsListToSnapshot = ( snapshot , project , nglViewList ) => async ( dispatch , getState ) => {
129
131
let projectID = project && project . projectID ;
@@ -2216,30 +2218,34 @@ export const getRedoActionText = () => (dispatch, getState) => {
2216
2218
return action ?. text ?? '' ;
2217
2219
} ;
2218
2220
2219
- export const appendAndSendTrackingActions = trackAction => ( dispatch , getState ) => {
2221
+ export const appendAndSendTrackingActions = trackAction => async ( dispatch , getState ) => {
2220
2222
const state = getState ( ) ;
2221
2223
const isUndoRedoAction = state . trackingReducers . isUndoRedoAction ;
2222
2224
dispatch ( setIsActionTracking ( true ) ) ;
2223
-
2224
2225
if ( trackAction && trackAction !== null ) {
2225
2226
const actionList = state . trackingReducers . track_actions_list ;
2226
2227
const sendActionList = state . trackingReducers . send_actions_list ;
2227
2228
const mergedActionList = mergeActions ( trackAction , [ ...actionList ] ) ;
2228
2229
const mergedSendActionList = mergeActions ( trackAction , [ ...sendActionList ] ) ;
2229
- dispatch ( setActionsList ( mergedActionList ) ) ;
2230
- dispatch ( setSendActionsList ( mergedSendActionList ) ) ;
2231
-
2230
+ dispatch ( setActionsList ( mergedActionList . list ) ) ;
2231
+ dispatch ( setSendActionsList ( mergedSendActionList . list ) ) ;
2232
2232
if ( isUndoRedoAction === false ) {
2233
2233
const undoRedoActionList = state . trackingReducers . undo_redo_actions_list ;
2234
2234
const mergedUndoRedoActionList = mergeActions ( trackAction , [ ...undoRedoActionList ] ) ;
2235
- dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList ) ) ;
2235
+ if ( mergedActionList . merged ) {
2236
+ dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList . list ) ) ;
2237
+ dispatch ( UndoActionCreators . removeLastPast ( ) ) ;
2238
+ } else {
2239
+ dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList . list ) ) ;
2240
+ }
2236
2241
}
2237
2242
}
2238
2243
dispatch ( setIsActionTracking ( false ) ) ;
2239
2244
dispatch ( checkSendTrackingActions ( ) ) ;
2240
2245
} ;
2241
2246
2242
2247
export const mergeActions = ( trackAction , list ) => {
2248
+ let merged = false ;
2243
2249
if ( needsToBeMerged ( trackAction ) ) {
2244
2250
let newList = [ ] ;
2245
2251
if ( list . length > 0 ) {
@@ -2248,16 +2254,18 @@ export const mergeActions = (trackAction, list) => {
2248
2254
trackAction . oldSetting = lastEntry . oldSetting ;
2249
2255
trackAction . text = trackAction . getText ( ) ;
2250
2256
newList = [ ...list . slice ( 0 , list . length - 1 ) , trackAction ] ;
2257
+ merged = true ;
2251
2258
} else {
2252
2259
newList = [ ...list , trackAction ] ;
2253
2260
}
2254
2261
} else {
2255
2262
newList . push ( trackAction ) ;
2256
2263
}
2257
- return newList ;
2264
+ return { merged : merged , list : newList } ;
2258
2265
} else {
2259
- return [ ...list , trackAction ] ;
2266
+ return { merged : merged , list : [ ...list , trackAction ] } ;
2260
2267
}
2268
+ // return {merged: merged, list: [...list, trackAction]};
2261
2269
} ;
2262
2270
2263
2271
const needsToBeMerged = trackAction => {
0 commit comments