Revert "fix: blocks not receiving their own delete events (#6655)" (#6675)

This reverts commit 485bd4dddf.
This commit is contained in:
Beka Westberg
2022-12-01 14:11:30 -08:00
committed by GitHub
parent 1cccc3cb4a
commit 089841c26f
3 changed files with 10 additions and 22 deletions

View File

@@ -20,7 +20,6 @@ import './events/events_block_create.js';
import './events/events_block_delete.js';
import {Blocks} from './blocks.js';
import {BlockDelete} from './events/events_block_delete.js';
import type {Comment} from './comment.js';
import * as common from './common.js';
import {Connection} from './connection.js';
@@ -331,6 +330,10 @@ export class Block implements IASTNodeLocation, IDeletable {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_DELETE))(this));
}
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
eventUtils.disable();
try {
@@ -1024,13 +1027,7 @@ export class Block implements IASTNodeLocation, IDeletable {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
this.onchange = onchangeFn;
this.onchangeWrapper_ = (e) => {
onchangeFn.call(this, e);
if (e.type === eventUtils.BLOCK_DELETE &&
(e as BlockDelete).blockId === this.id) {
this.workspace.removeChangeListener(this.onchangeWrapper_!);
}
};
this.onchangeWrapper_ = onchangeFn.bind(this);
this.workspace.addChangeListener(this.onchangeWrapper_);
}