@@ -28,7 +28,7 @@ import {
2828 createEventInstance ,
2929 regenerateAllEventDeps ,
3030} from 'libs' ;
31- import { timeTraveler } from 'libs/history' ;
31+ import { timeTraveler , actionWithSnapshot } from 'libs/history' ;
3232import { getMaterialsActionMeta } from 'runtime' ;
3333import { selectStore , SelectType } from './select' ;
3434import { componentsStore } from './components' ;
@@ -40,13 +40,13 @@ import { pagesStore } from './pages';
4040export class EventStore {
4141 constructor ( ) {
4242 timeTraveler . onRestore ( ( type , nextSnapshots , currentSnapshots ) => {
43- if ( nextSnapshots . payload . needReloadDeps || currentSnapshots . payload . needReloadDeps ) {
43+ if ( nextSnapshots ? .payload ? .needReloadDeps || currentSnapshots ? .payload ? .needReloadDeps ) {
4444 regenerateAllEventDeps ( ) ;
4545 }
4646 } ) ;
4747 }
4848
49- @action
49+ @actionWithSnapshot ( { needReloadDeps : true } )
5050 public addEventInstance = ( triggerName : EventTriggerName , target : EventTarget ) => {
5151 const action = target . type === EventTargetType . Action ? getMaterialsActionMeta ( target . id ) ! : undefined ;
5252
@@ -183,7 +183,7 @@ export class EventStore {
183183 }
184184 } ;
185185
186- @action
186+ @actionWithSnapshot ( { needReloadDeps : true } )
187187 public deleteEventInstance = ( index : number ) => {
188188 let eventInstance : EventInstance ;
189189 switch ( selectStore . selectType ) {
@@ -276,7 +276,7 @@ export class EventStore {
276276 }
277277 } ;
278278
279- @action
279+ @actionWithSnapshot ( { needReloadDeps : true } )
280280 public deleteDepsEventInstances = ( type : DepsTargetType , key : number ) => {
281281 let deps : Maybe < DepFrom [ ] > ;
282282 switch ( type ) {
@@ -323,42 +323,42 @@ export class EventStore {
323323 } ) ;
324324 } ;
325325
326- @action
326+ @actionWithSnapshot
327327 public setEventInstanceDataOfCurrentComponentInstance = ( data : object , index : number ) => {
328328 return componentsStore . setCurrentComponentInstanceEvents ( events => {
329329 events [ index ] ! . data = data ;
330330 } ) ;
331331 } ;
332332
333- @action
333+ @actionWithSnapshot
334334 public setEventInstanceDataOfCurrentPluginInstance = ( data : object , index : number ) => {
335335 return pluginsStore . setCurrentPluginInstanceEvents ( events => {
336336 events [ index ] ! . data = data ;
337337 } ) ;
338338 } ;
339339
340- @action
340+ @actionWithSnapshot
341341 public setEventInstanceDataOfCurrentHotArea = ( data : object , index : number ) => {
342342 return hotAreaStore . setCurrentHotAreaEvents ( events => {
343343 events [ index ] ! . data = data ;
344344 } ) ;
345345 } ;
346346
347- @action
347+ @actionWithSnapshot
348348 public setEventInstanceDataOfGlobal = ( data : object , index : number ) => {
349349 return globalStore . setGlobalEvents ( events => {
350350 events [ index ] ! . data = data ;
351351 } ) ;
352352 } ;
353353
354- @action
354+ @actionWithSnapshot
355355 public setEventInstanceDataOfCurrentPage = ( data : object , index : number ) => {
356356 return pagesStore . setCurrentPage ( page => {
357357 page . events [ index ] ! . data = data ;
358358 } ) ;
359359 } ;
360360
361- @action
361+ @actionWithSnapshot
362362 public resortEventInstanceFromCurrentComponentInstance = ( oldIndex : number , newIndex : number ) => {
363363 if ( oldIndex === newIndex ) {
364364 return ;
@@ -370,7 +370,7 @@ export class EventStore {
370370 } ) ;
371371 } ;
372372
373- @action
373+ @actionWithSnapshot
374374 public resortEventInstanceFromCurrentPluginInstance = ( oldIndex : number , newIndex : number ) => {
375375 if ( oldIndex === newIndex ) {
376376 return ;
@@ -382,7 +382,7 @@ export class EventStore {
382382 } ) ;
383383 } ;
384384
385- @action
385+ @actionWithSnapshot
386386 public resortEventInstanceFromCurrentHotArea = ( oldIndex : number , newIndex : number ) => {
387387 if ( oldIndex === newIndex ) {
388388 return ;
@@ -394,7 +394,7 @@ export class EventStore {
394394 } ) ;
395395 } ;
396396
397- @action
397+ @actionWithSnapshot
398398 public resortEventInstanceFromGlobal = ( oldIndex : number , newIndex : number ) => {
399399 if ( oldIndex === newIndex ) {
400400 return ;
0 commit comments