MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / revert

Method revert

src/actions/HideImage.ts:103–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101 }
102
103 override async revert(): Promise<void> {
104 // return this.engine.run (this.engine.history ('image').pop (), false);
105 const history = this.engine.history('image') as string[];
106 for (let i = history.length - 1; i >= 0; i--) {
107 const last = history[i];
108 const [, , asset] = last.split(' ');
109 if (asset === this.asset) {
110 const action = this.engine.prepareAction(last, { cycle: 'Application' }) as import('../lib/types').ActionInstance | null;
111 if (action !== null) {
112 await action.willApply();
113 await action.apply();
114 await action.didApply({ updateHistory: false, updateState: true });
115 }
116 return;
117 }
118 }
119
120 throw new Error('Could not find a previous state to revert to');
121 }
122
123 override async didRevert(): Promise<ActionRevertResult> {
124 return { advance: true, step: true };

Callers

nothing calls this directly

Calls 5

historyMethod · 0.80
prepareActionMethod · 0.80
willApplyMethod · 0.45
applyMethod · 0.45
didApplyMethod · 0.45

Tested by

no test coverage detected