mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Add a runtime event to track when the toolbox extension blocks need updating.
This commit is contained in:
parent
91f0d59be0
commit
92a73fef55
2 changed files with 24 additions and 1 deletions
|
@ -509,6 +509,14 @@ class Runtime extends EventEmitter {
|
|||
return 'PROJECT_CHANGED';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for report that a change was made that can be saved
|
||||
* @const {string}
|
||||
*/
|
||||
static get TOOLBOX_EXTENSIONS_NEED_UPDATE () {
|
||||
return 'TOOLBOX_EXTENSIONS_NEED_UPDATE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Event name for targets update report.
|
||||
* @const {string}
|
||||
|
@ -1963,10 +1971,15 @@ class Runtime extends EventEmitter {
|
|||
* @param {!Target} editingTarget New editing target.
|
||||
*/
|
||||
setEditingTarget (editingTarget) {
|
||||
const oldEditingTarget = this._editingTarget;
|
||||
this._editingTarget = editingTarget;
|
||||
// Script glows must be cleared.
|
||||
this._scriptGlowsPreviousFrame = [];
|
||||
this._updateGlows();
|
||||
|
||||
if (oldEditingTarget !== this._editingTarget) {
|
||||
this.requestToolboxExtensionsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2384,12 +2397,19 @@ class Runtime extends EventEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Emit an event that indicate that the blocks on the workspace need updating.
|
||||
* Emit an event that indicates that the blocks on the workspace need updating.
|
||||
*/
|
||||
requestBlocksUpdate () {
|
||||
this.emit(Runtime.BLOCKS_NEED_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit an event that indicates that the toolbox extension blocks need updating.
|
||||
*/
|
||||
requestToolboxExtensionsUpdate () {
|
||||
this.emit(Runtime.TOOLBOX_EXTENSIONS_NEED_UPDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up timers to repeatedly step in a browser.
|
||||
*/
|
||||
|
|
|
@ -121,6 +121,9 @@ class VirtualMachine extends EventEmitter {
|
|||
this.runtime.on(Runtime.BLOCKS_NEED_UPDATE, () => {
|
||||
this.emitWorkspaceUpdate();
|
||||
});
|
||||
this.runtime.on(Runtime.TOOLBOX_EXTENSIONS_NEED_UPDATE, () => {
|
||||
this.extensionManager.refreshBlocks();
|
||||
});
|
||||
this.runtime.on(Runtime.PERIPHERAL_LIST_UPDATE, info => {
|
||||
this.emit(Runtime.PERIPHERAL_LIST_UPDATE, info);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue