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

Method revert

src/actions/ShowBackground.ts:128–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 }
127
128 override async revert(): Promise<void> {
129 let history = this.engine.history('background') as string[];
130
131 history.pop();
132
133 if (history.length === 0) {
134 history = this.engine.history('scene') as string[];
135 history.pop();
136 this.engine.global('_scene_history_cleared_by_background', true);
137 }
138
139 if (history.length > 0) {
140 const background = this.engine.element().find('[data-ui="background"]');
141 const last = history[history.length - 1].replace('show scene', 'show background');
142 const action = this.engine.prepareAction(last, { cycle: 'Application' }) as (ActionInstance & { property?: string; value?: string; classes?: string[] }) | null;
143
144 background.style('background-image', 'initial');
145 background.style('background-color', 'initial');
146 if (action !== null && action.property && action.value) {
147 background.style(action.property, action.value);
148 }
149
150 // Use the previous background's classes, not the current one being reverted
151 const classesToApply = action?.classes ?? [];
152 for (const newClass of classesToApply) {
153 background.addClass(newClass);
154 }
155
156 this.engine.state({
157 background: last
158 });
159 }
160 }
161
162 override async didRevert(): Promise<ActionRevertResult> {
163 return { advance: true, step: true };

Callers

nothing calls this directly

Calls 7

historyMethod · 0.80
globalMethod · 0.80
replaceMethod · 0.80
prepareActionMethod · 0.80
stateMethod · 0.80
popMethod · 0.45
elementMethod · 0.45

Tested by

no test coverage detected