Skip to content

Commit

Permalink
async_function_conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
kaurjasleen240305 committed Jan 5, 2024
1 parent bb4cae2 commit f2be063
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -1216,81 +1216,79 @@ class Activity {
/*
* Increases block size
*/
const doLargerBlocks = (activity) => {
activity._doLargerBlocks();
const doLargerBlocks = async(activity) => {
await activity._doLargerBlocks();
};

this._doLargerBlocks = () => {
this._doLargerBlocks = async() => {
this.blocks.activeBlock = null;

if (!this.resizeDebounce) {
if (this.blockscale < BLOCKSCALES.length - 1) {
this.resizeDebounce = true;
this.blockscale += 1;
this.blocks.setBlockScale(BLOCKSCALES[this.blockscale]);

const that = this;
setTimeout(() => {
that.resizeDebounce = false;
}, 3000);
await this.blocks.setBlockScale(BLOCKSCALES[this.blockscale]);
}

this.setSmallerLargerStatus();
const that = this;
that.resizeDebounce = false;
await this.setSmallerLargerStatus();

}
if(typeof(this.activity)!="undefined"){
this.activity.refreshCanvas();
}
await this.activity.refreshCanvas();
}
document.getElementById("hideContents").click();
};

/*
* Decreases block size
*/
const doSmallerBlocks = (activity) => {
activity._doSmallerBlocks();
const doSmallerBlocks = async(activity) => {
await activity._doSmallerBlocks();
};

this._doSmallerBlocks = () => {
this._doSmallerBlocks = async() => {
this.blocks.activeBlock = null;

if (!this.resizeDebounce) {
if (this.blockscale > 0) {
this.resizeDebounce = true;
this.blockscale -= 1;
this.blocks.setBlockScale(BLOCKSCALES[this.blockscale]);
await this.blocks.setBlockScale(BLOCKSCALES[this.blockscale]);
}

const that = this;
setTimeout(() => {
that.resizeDebounce = false;
}, 3000);
that.resizeDebounce = false;

}

this.setSmallerLargerStatus();
await this.setSmallerLargerStatus();
if(typeof(this.activity)!="undefined"){
this.activity.refreshCanvas();
}
await this.activity.refreshCanvas();
}
document.getElementById("hideContents").click();
};

/*
* If either the block size has reached its minimum or maximum,
* then the icons to make them smaller/bigger will be hidden.
*/
this.setSmallerLargerStatus = () => {
this.setSmallerLargerStatus = async() => {
if (BLOCKSCALES[this.blockscale] < DEFAULTBLOCKSCALE) {
changeImage(this.smallerContainer.children[0], SMALLERBUTTON, SMALLERDISABLEBUTTON);
await changeImage(this.smallerContainer.children[0], SMALLERBUTTON, SMALLERDISABLEBUTTON);
} else {
changeImage(this.smallerContainer.children[0], SMALLERDISABLEBUTTON, SMALLERBUTTON);
await changeImage(this.smallerContainer.children[0], SMALLERDISABLEBUTTON, SMALLERBUTTON);
}

if (BLOCKSCALES[this.blockscale] === 4) {
changeImage(this.largerContainer.children[0], BIGGERBUTTON, BIGGERDISABLEBUTTON);
await changeImage(this.largerContainer.children[0], BIGGERBUTTON, BIGGERDISABLEBUTTON);
} else {
changeImage(this.largerContainer.children[0], BIGGERDISABLEBUTTON, BIGGERBUTTON);
await changeImage(this.largerContainer.children[0], BIGGERDISABLEBUTTON, BIGGERBUTTON);
}
};


/*
* Based on the active palette, remove a plugin palette from local storage.
*/
Expand Down

0 comments on commit f2be063

Please sign in to comment.