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

Method didApply

src/actions/Play.ts:380–402  ·  view source on GitHub ↗
({ updateHistory = true, updateState = true } = {})

Source from the content-addressed store, hash-verified

378 }
379
380 override async didApply({ updateHistory = true, updateState = true } = {}): Promise<ActionApplyResult> {
381 if (updateHistory === true) {
382 if (this.player instanceof AudioPlayer || this.mediaKey) {
383 this.engine.history(this.type).push(this._statement as string);
384 }
385 }
386
387 if (updateState === true) {
388 const currentState = this.engine.state(this.type);
389 if (this.player instanceof AudioPlayer || this.mediaKey) {
390 const newItem: MediaStateItem = { statement: this._statement as string, paused: false };
391 this.engine.state({ [this.type]: [...currentState, newItem] });
392 } else if (this.player instanceof Array) {
393 const updatedState = currentState.map((item: MediaStateItem) => ({
394 ...item,
395 paused: false
396 }));
397 this.engine.state({ [this.type]: updatedState });
398 }
399 }
400
401 return { advance: true };
402 }
403
404 override async revert(): Promise<void> {
405 if (typeof this.mediaKey !== 'undefined') {

Callers 1

onLoadMethod · 0.45

Calls 2

historyMethod · 0.80
stateMethod · 0.80

Tested by

no test coverage detected