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.emitProjectChanged();
this.resetCache(); this.resetCache();

View file

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