Skip to content

Commit

Permalink
fix: button doesn't respond after first task done
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Mar 8, 2023
1 parent 59b7de4 commit 51d16b1
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/launcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,30 @@ export async function createLauncher({

const taskQueue: AsyncGenerator<any, void, () => CommonUpdateProgram> =
(async function* () {
const task = yield 0;
setBusy(true);
try {
for await (const text of task()) {
switch (text[0]) {
case "setProgress":
setProgress(text[1]);
break;
case "setUndeterminedProgress":
setProgress(0);
break;
case "setStateText":
setStatusText(text[1]); //FIXME: locales
break;
while (true) {
const task = yield 0;
setBusy(true);
try {
for await (const text of task()) {
switch (text[0]) {
case "setProgress":
setProgress(text[1]);
break;
case "setUndeterminedProgress":
setProgress(0);
break;
case "setStateText":
setStatusText(text[1]); //FIXME: locales
break;
}
}
} catch (e) {
// fatal
await fatal(e);
return;
}
} catch (e) {
// fatal
await fatal(e);
return;
setBusy(false);
}
setBusy(false);
})();
taskQueue.next(); // ignored anyway

Expand Down Expand Up @@ -237,7 +239,7 @@ export async function createLauncher({
<Button
mr="-1px"
disabled={programBusy()}
onClick={onButtonClick}
onClick={() => onButtonClick().catch(fatal)}
>
{_gameInstalled() ? "LAUNCH" : "INSTALL"}
</Button>
Expand Down

0 comments on commit 51d16b1

Please sign in to comment.