-
Notifications
You must be signed in to change notification settings - Fork 0
Add auto-updater functionality using Tauri v2 updater plugin #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -78,6 +78,14 @@ | |||||||
| "scope": [ | ||||||||
| "**" | ||||||||
| ] | ||||||||
| }, | ||||||||
| "updater": { | ||||||||
| "active": true, | ||||||||
| "endpoints": [ | ||||||||
| "https://github.com/syntaxfm/production-assistant/releases/latest/download/latest.json" | ||||||||
| ], | ||||||||
| "dialog": true, | ||||||||
| "pubkey": "" | ||||||||
|
||||||||
| "pubkey": "" | |
| "pubkey": "", | |
| "pubkeyComment": "Empty pubkey is for development only. Do not use in production." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,47 @@ | |
| import Avatar from '$lib/auth/Avatar.svelte'; | ||
| import ProjectButton from '$/lib/components/ProjectButton.svelte'; | ||
| app_data.sync(); | ||
|
|
||
| let isCheckingUpdates = $state(false); | ||
| let updateMessage = $state(''); | ||
|
|
||
| async function checkForUpdates() { | ||
| isCheckingUpdates = true; | ||
| updateMessage = ''; | ||
| try { | ||
| const result = await invoke('check_for_updates'); | ||
|
||
| updateMessage = result as string; | ||
|
|
||
| // If update is available, offer to install | ||
| if ((result as string).includes('Update available')) { | ||
| const shouldInstall = confirm(`${result}\n\nWould you like to install the update now?`); | ||
| if (shouldInstall) { | ||
| await installUpdate(); | ||
| } | ||
| } else { | ||
| alert(result); | ||
| } | ||
|
Comment on lines
+20
to
+27
|
||
| } catch (error) { | ||
| const errorMsg = `Error checking for updates: ${error}`; | ||
| updateMessage = errorMsg; | ||
| alert(errorMsg); | ||
| } finally { | ||
| isCheckingUpdates = false; | ||
| } | ||
| } | ||
|
|
||
| async function installUpdate() { | ||
| try { | ||
| updateMessage = 'Installing update...'; | ||
| const result = await invoke('install_update'); | ||
| updateMessage = result as string; | ||
| alert(result); | ||
| } catch (error) { | ||
| const errorMsg = `Error installing update: ${error}`; | ||
| updateMessage = errorMsg; | ||
| alert(errorMsg); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <div class="content"> | ||
|
|
@@ -27,6 +68,9 @@ | |
| /></label | ||
| > | ||
| <button class="small ghost" onclick={app_data.export_to_json}>Export Data</button> | ||
| <button class="small ghost" onclick={checkForUpdates} disabled={isCheckingUpdates}> | ||
| {isCheckingUpdates ? 'Checking...' : 'Check for Updates'} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| <div class="grid"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
install_updatefunction callsupdater.check().awaitagain, which duplicates the network request that was already made incheck_for_updates. Consider caching the update information or restructuring the flow to avoid redundant API calls.