Skip to content

Commit bde8e7a

Browse files
authored
Merge pull request #324 from adzhindzhi/uepr-333-loading-extension-alert-continues-to-display-on-error
[UEPR-333] Fix "Loading extension" alert not closing on error
2 parents d941b9d + ed97273 commit bde8e7a

File tree

1 file changed

+11
-1
lines changed
  • packages/scratch-vm/src/extensions/scratch3_face_sensing

1 file changed

+11
-1
lines changed

packages/scratch-vm/src/extensions/scratch3_face_sensing/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ class Scratch3FaceSensingBlocks {
219219
*/
220220
_loop () {
221221
setTimeout(this._loop.bind(this), Math.max(this.runtime.currentStepTime, Scratch3FaceSensingBlocks.INTERVAL));
222+
223+
// Close the alert if the face detector is created and the video loading has either succeeded or failed.
224+
// The alert will remain open until the permissions are set
225+
if (!this._firstTime && this._videoLoadingCompleted) {
226+
this.runtime.emit('EXTENSION_DATA_LOADING', false);
227+
this._firstTime = true;
228+
}
222229

223230
const frame = this.runtime.ioDevices.video.getFrame({
224231
format: Video.FORMAT_IMAGE_DATA,
@@ -270,7 +277,10 @@ class Scratch3FaceSensingBlocks {
270277
*/
271278
getInfo () {
272279
// Enable the video layer
273-
this.runtime.ioDevices.video.enableVideo();
280+
this.runtime.ioDevices.video.enableVideo()
281+
.finally(() => {
282+
this._videoLoadingCompleted = true;
283+
});
274284

275285
return {
276286
id: 'faceSensing',

0 commit comments

Comments
 (0)