Code cleanup -- move out duplicate .then statements after the next .then (at the higher level)

This commit is contained in:
Karishma Chadha 2019-01-30 16:45:38 -05:00
parent 94cc7e66b6
commit 13e69bad7b
2 changed files with 3 additions and 6 deletions

View file

@ -674,8 +674,6 @@ class Blocks {
}
}
// TODO maybe track actual changes,
// but for now, emit a project change always
this.emitProjectChanged();
this.resetCache();

View file

@ -562,15 +562,14 @@ class VirtualMachine extends EventEmitter {
.then(validatedInput => {
const projectVersion = validatedInput[0].projectVersion;
if (projectVersion === 2) {
return this._addSprite2(validatedInput[0], validatedInput[1])
.then(() => this.runtime.emitProjectChanged());
return this._addSprite2(validatedInput[0], validatedInput[1]);
}
if (projectVersion === 3) {
return this._addSprite3(validatedInput[0], validatedInput[1])
.then(() => this.runtime.emitProjectChanged());
return this._addSprite3(validatedInput[0], validatedInput[1]);
}
return Promise.reject(`${errorPrefix} Unable to verify sprite version.`);
})
.then(() => this.runtime.emitProjectChanged())
.catch(error => {
// Intentionally rejecting here (want errors to be handled by caller)
if (error.hasOwnProperty('validationError')) {