Skip to content

Commit

Permalink
feat: introduce delay between devices
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves authored Aug 15, 2023
1 parent b2d8c4e commit 83d79ca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,19 @@
};
}

function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

const applyColors = debounce(async (colorString) => {
const { clientId, clientSecret, deviceIds } = await getProperties();

deviceIds.forEach((deviceId) =>
fetch("/tap/" + deviceId + "/" + colorString, {
for (const deviceId of deviceIds) {
await fetch("/tap/" + deviceId + "/" + colorString, {
headers: { clientId, clientSecret },
})
);
});
await delay(200);
}
});

window.addEventListener("DOMContentLoaded", async () => {
Expand Down

0 comments on commit 83d79ca

Please sign in to comment.