@@ -125,6 +125,7 @@ import {
125
125
setInspirationMoleculeDataList
126
126
} from '../../components/datasets/redux/actions' ;
127
127
import { selectVectorAndResetCompounds } from '../../../js/reducers/selection/dispatchActions' ;
128
+ import { ActionCreators as UndoActionCreators } from '../../undoredo/actions'
128
129
129
130
export const addCurrentActionsListToSnapshot = ( snapshot , project , nglViewList ) => async ( dispatch , getState ) => {
130
131
let projectID = project && project . projectID ;
@@ -2231,7 +2232,12 @@ export const appendAndSendTrackingActions = trackAction => async (dispatch, getS
2231
2232
if ( isUndoRedoAction === false ) {
2232
2233
const undoRedoActionList = state . trackingReducers . undo_redo_actions_list ;
2233
2234
const mergedUndoRedoActionList = mergeActions ( trackAction , [ ...undoRedoActionList ] ) ;
2234
- dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList . list ) ) ;
2235
+ if ( mergedActionList . merged ) {
2236
+ dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList . list ) ) ;
2237
+ dispatch ( UndoActionCreators . removeLastPast ( ) ) ;
2238
+ } else {
2239
+ dispatch ( setUndoRedoActionList ( mergedUndoRedoActionList . list ) ) ;
2240
+ }
2235
2241
}
2236
2242
}
2237
2243
dispatch ( setIsActionTracking ( false ) ) ;
@@ -2240,26 +2246,26 @@ export const appendAndSendTrackingActions = trackAction => async (dispatch, getS
2240
2246
2241
2247
export const mergeActions = ( trackAction , list ) => {
2242
2248
let merged = false ;
2243
- // if (needsToBeMerged(trackAction)) {
2244
- // let newList = [];
2245
- // if (list.length > 0) {
2246
- // const lastEntry = list[list.length - 1];
2247
- // if (isSameTypeOfAction(trackAction, lastEntry) && isActionWithinTimeLimit(lastEntry, trackAction)) {
2248
- // trackAction.oldSetting = lastEntry.oldSetting;
2249
- // trackAction.text = trackAction.getText();
2250
- // newList = [...list.slice(0, list.length - 1), trackAction];
2251
- // merged = true;
2252
- // } else {
2253
- // newList = [...list, trackAction];
2254
- // }
2255
- // } else {
2256
- // newList.push(trackAction);
2257
- // }
2258
- // return {merged: merged, list: newList};
2259
- // } else {
2260
- // return {merged: merged, list: [...list, trackAction]};
2261
- // }
2262
- return { merged : merged , list : [ ...list , trackAction ] } ;
2249
+ if ( needsToBeMerged ( trackAction ) ) {
2250
+ let newList = [ ] ;
2251
+ if ( list . length > 0 ) {
2252
+ const lastEntry = list [ list . length - 1 ] ;
2253
+ if ( isSameTypeOfAction ( trackAction , lastEntry ) && isActionWithinTimeLimit ( lastEntry , trackAction ) ) {
2254
+ trackAction . oldSetting = lastEntry . oldSetting ;
2255
+ trackAction . text = trackAction . getText ( ) ;
2256
+ newList = [ ...list . slice ( 0 , list . length - 1 ) , trackAction ] ;
2257
+ merged = true ;
2258
+ } else {
2259
+ newList = [ ...list , trackAction ] ;
2260
+ }
2261
+ } else {
2262
+ newList . push ( trackAction ) ;
2263
+ }
2264
+ return { merged : merged , list : newList } ;
2265
+ } else {
2266
+ return { merged : merged , list : [ ...list , trackAction ] } ;
2267
+ }
2268
+ // return {merged: merged, list: [...list, trackAction]};
2263
2269
} ;
2264
2270
2265
2271
const needsToBeMerged = trackAction => {
0 commit comments