-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ability to upgrade to latest daemon while the app is running
- Loading branch information
1 parent
a9ea86a
commit ed1c1ff
Showing
18 changed files
with
176 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,81 @@ | ||
'use client' | ||
|
||
import { Text } from '@siafoundation/design-system' | ||
import { | ||
LoadingDots, | ||
Text, | ||
triggerErrorToast, | ||
triggerSuccessToast, | ||
} from '@siafoundation/design-system' | ||
import { Upgrade16 } from '@siafoundation/react-icons' | ||
import { useLatestVersion } from './useLatestVersion' | ||
import { useInstalledVersion } from './useInstalledVersion' | ||
import { useCallback, useState } from 'react' | ||
|
||
export function UpdateBanner() { | ||
const latestVersion = useLatestVersion() | ||
const installedVersion = useInstalledVersion() | ||
const [isUpdating, setIsUpdating] = useState(false) | ||
const [isRestarting, setIsRestarting] = useState(false) | ||
|
||
const update = useCallback(async () => { | ||
try { | ||
setIsUpdating(true) | ||
await window.electron.daemonUpdate() | ||
} catch (e) { | ||
console.log(e) | ||
triggerErrorToast('Error downloading update. Please try again.') | ||
setIsUpdating(false) | ||
setIsRestarting(false) | ||
return | ||
} | ||
try { | ||
setIsRestarting(true) | ||
await window.electron.daemonStart() | ||
} catch (e) { | ||
console.log(e) | ||
triggerErrorToast('Error restarting daemon. Please try again.') | ||
setIsUpdating(false) | ||
setIsRestarting(false) | ||
return | ||
} | ||
triggerSuccessToast(`Updated to hostd version ${installedVersion.data}.`) | ||
setIsUpdating(false) | ||
setIsRestarting(false) | ||
}, [setIsUpdating, installedVersion.data]) | ||
|
||
if (latestVersion.data === installedVersion.data) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="flex w-full gap-2 items-center justify-center py-2 px-3 bg-amber-600 dark:bg-amber-500"> | ||
<Text color="lo"> | ||
<Upgrade16 /> | ||
</Text> | ||
<Text size="14" color="lo"> | ||
An update to version {latestVersion.data} is available. | ||
</Text> | ||
<div | ||
className="flex w-full gap-2 items-center justify-center py-2 px-3 bg-amber-600 dark:bg-amber-500 cursor-pointer" | ||
onClick={update} | ||
> | ||
{isRestarting ? ( | ||
<> | ||
<LoadingDots /> | ||
<Text size="14" color="lo"> | ||
Restarting hostd daemon {latestVersion.data} | ||
</Text> | ||
</> | ||
) : isUpdating ? ( | ||
<> | ||
<LoadingDots /> | ||
<Text size="14" color="lo"> | ||
Updating to hostd {latestVersion.data} | ||
</Text> | ||
</> | ||
) : ( | ||
<> | ||
<Text color="lo"> | ||
<Upgrade16 /> | ||
</Text> | ||
<Text size="14" color="lo"> | ||
An update to hostd {latestVersion.data} is available. | ||
</Text> | ||
</> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.