Skip to content

Commit f571624

Browse files
authored
wait 1 second so the block list can update
1 parent baddf8f commit f571624

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/addons/addons/block-count/blockcount.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export default async function ({ addon, console, msg }) {
55
let counterElement;
66

77
const getBlockCount = () => {
8-
let allBlockCount = 0; // number of blocks in project
9-
let thisBlockCount = 0; // number of blocks in this sprite
10-
8+
let blockCount = 0;
119
const targetBlocks = vm.runtime.targets.map((target) => {
1210
return [
1311
target.id,
@@ -17,14 +15,14 @@ export default async function ({ addon, console, msg }) {
1715
});
1816

1917
// project block count
20-
for (const info of targetBlocks) allBlockCount += info[1];
18+
for (const info of targetBlocks) blockCount += info[1];
2119

2220
// this sprite's block count
2321
const thisTargetID = vm.editingTarget?.id;
2422
const thisWS = targetBlocks.find((i) => i[0] === thisTargetID);
2523
if (thisWS) thisBlockCount += thisWS[1];
2624

27-
return [thisBlockCount, allBlockCount];
25+
return blockCount;
2826
};
2927

3028
const addCounter = () => {
@@ -70,7 +68,7 @@ export default async function ({ addon, console, msg }) {
7068
(event.type === events.DELETE || event.type === events.CREATE)
7169
) {
7270
lastUpdateTime = now;
73-
updateText();
71+
setTimeout(updateText, 1000);
7472
}
7573
};
7674

0 commit comments

Comments
 (0)