Skip to content

Commit

Permalink
fix: reset not working
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves authored Aug 21, 2023
1 parent f6f3317 commit eaa4602
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
}
}

const applyColor = async (colorString) => {
const applyColor = async (color) => {
speak(color.name);

const colorString = [color.angle, 100, 100].join(",");
const { clientId, clientSecret, deviceIds } = await getProperties();

for (const deviceId of deviceIds) {
Expand All @@ -86,7 +89,7 @@
const { clientId, clientSecret, deviceIds } = await getProperties();

for (const deviceId of deviceIds) {
await fetch("/reset/" + deviceIds, {
await fetch("/reset/" + deviceId, {
headers: { clientId, clientSecret },
});
}
Expand All @@ -109,13 +112,11 @@
const changeColor = async function () {
const index = 1 + (Math.floor(Math.random() * 100) % colors.length) - 1;
const color = colors[index];
const colorString = [color.angle, 100, 100].join(",");

main.style.backgroundColor = color.rgb;
theme.content = color.rgb;

speak(color.name);
apply(colorString);
apply(color);
};

function startChange() {
Expand Down
4 changes: 2 additions & 2 deletions server/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ async function handle(req, res, fn) {

export default async function (req, res, next) {
if (req.url.startsWith("/tap/")) {
handle(req, res, onTap);
return handle(req, res, onTap);
}

if (req.url.startsWith("/reset/")) {
handle(req, res, onReset);
return handle(req, res, onReset);
}

next();
Expand Down

0 comments on commit eaa4602

Please sign in to comment.