Skip to content

Commit

Permalink
fix: hanging update button
Browse files Browse the repository at this point in the history
  • Loading branch information
billyjacoby committed Nov 3, 2023
1 parent c2158fd commit 4ae5c74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "browsernaut",
"private": true,
"version": "1.1.1",
"version": "1.1.2",
"type": "module",
"scripts": {
"app:version": "echo $npm_package_version",
Expand Down
21 changes: 8 additions & 13 deletions src/views/Preferences/components/tabs/TabAbout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,20 @@ export const TabAbout = (): JSX.Element => {
setIsCheckingForUpdate(true);
setUpdateButtonContent('Checking for update.');

try {
const interval = setInterval(() => {
setUpdateButtonContent((prev) => {
if (prev.endsWith('...')) {
return prev.replace('...', '.');
}
return prev + '.';
});
}, 500);
const resetTimeout = setTimeout(() => {
setIsCheckingForUpdate(false);
setUpdateButtonContent(BUTTON_UPDATE_STRING);
}, 6000);

try {
const updateResult = await checkUpdate();
clearInterval(interval);

if (updateResult.shouldUpdate) {
const result = await confirm(
'There is an update available. Would you like to update now?'
);

//? This isn't working as expected, the promise seems to never resolve if the user clicks no.
clearTimeout(resetTimeout);
setUpdateButtonContent('Update available!');
if (result) {
await installUpdate();
return;
Expand Down Expand Up @@ -74,7 +70,6 @@ export const TabAbout = (): JSX.Element => {
>
{updateButtonContent}
</Button>

<div className="gap-4 mt-auto mb-8">
<p>Copyright © Billy Jacoby</p>
<Button variant={'link'} onClick={() => openURL({ URL: HOMEPAGE_URL })}>
Expand Down

0 comments on commit 4ae5c74

Please sign in to comment.