Compare commits

...

20 Commits

Author SHA1 Message Date
d2912a9392 Updater test from franknoirot/update-download-progress 2024-10-10 05:00:38 -04:00
ea86ee41ca Merge branch 'main' into franknoirot/update-download-progress 2024-10-10 04:59:29 -04:00
f85e44db73 Merge branch 'main' into franknoirot/update-download-progress 2024-10-09 18:20:59 -04:00
6a459b3bdd A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) 2024-10-04 17:17:27 +00:00
f9032bdddb Update .github/workflows/build-test-publish-apps.yml
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
2024-10-04 13:07:40 -04:00
d3e79cfeaa fmt 2024-10-03 14:34:17 -04:00
910ceaf578 A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) 2024-10-03 18:24:05 +00:00
ed1bb4b751 Merge branch 'main' into franknoirot/update-download-progress 2024-10-03 14:19:50 -04:00
23aa06b486 Make the loading toast not attempt to display a version number 2024-10-03 14:19:24 -04:00
14cc08e187 Switch branch to build-publish-apps on to this one 2024-10-03 14:19:08 -04:00
06fcb733c9 Revert "Temporarily turn on artifact builds to test"
This reverts commit e2e1991977.
2024-10-03 14:15:16 -04:00
1a7d587af8 Flatten autoupdater hooks 2024-10-02 07:31:20 -04:00
df8d3740b6 Add an update-error listener 2024-09-26 12:03:42 -04:00
15b42eb8b7 A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) 2024-09-26 15:42:31 +00:00
012fc95da0 Update src/index.tsx 2024-09-26 11:38:24 -04:00
bb13953393 Update src/index.tsx 2024-09-26 11:38:12 -04:00
0deaf8c0a6 Oops forgot to rename where I used a type 2024-09-26 10:46:02 -04:00
540ce2c8e6 fmt 2024-09-26 10:44:46 -04:00
e2e1991977 Temporarily turn on artifact builds to test 2024-09-26 10:36:49 -04:00
53314dd387 Add a loading toast when update download begins 2024-09-26 10:34:33 -04:00
9 changed files with 56 additions and 4 deletions

View File

@ -5,6 +5,7 @@ on:
push:
branches:
- main
- pierremtb/update-download-progress-updater-test
release:
types: [published]
schedule:
@ -13,8 +14,8 @@ on:
# Will checkout the last commit from the default branch (main as of 2023-10-04)
env:
CUT_RELEASE_PR: ${{ github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'Cut release v')) }}
BUILD_RELEASE: ${{ github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'Cut release v')) }}
CUT_RELEASE_PR: true
BUILD_RELEASE: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 44 KiB

4
interface.d.ts vendored
View File

@ -69,9 +69,13 @@ export interface IElectronAPI {
kittycad: (access: string, args: any) => any
listMachines: () => Promise<MachinesListing>
getMachineApiIp: () => Promise<string | null>
onUpdateDownloadStart: (
callback: (value: { version: string }) => void
) => Electron.IpcRenderer
onUpdateDownloaded: (
callback: (value: string) => void
) => Electron.IpcRenderer
onUpdateError: (callback: (value: { error: Error }) => void) => Electron
appRestart: () => void
}

View File

@ -8,6 +8,7 @@ import ModalContainer from 'react-modal-promise'
import { isDesktop } from 'lib/isDesktop'
import { AppStreamProvider } from 'AppState'
import { ToastUpdate } from 'components/ToastUpdate'
import { AUTO_UPDATER_TOAST_ID } from 'lib/constants'
// uncomment for xstate inspector
// import { DEV } from 'env'
@ -53,7 +54,22 @@ root.render(
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals()
isDesktop() &&
if (isDesktop()) {
// Listen for update download progress to begin
// to show a loading toast.
window.electron.onUpdateDownloadStart(() => {
const message = `Downloading app update...`
console.log(message)
toast.loading(message, { id: AUTO_UPDATER_TOAST_ID })
})
// Listen for update download errors to show
// an error toast and clear the loading toast.
window.electron.onUpdateError(({ error }) => {
console.error(error)
toast.error('An error occurred while downloading the update.', {
id: AUTO_UPDATER_TOAST_ID,
})
})
window.electron.onUpdateDownloaded((version: string) => {
const message = `A new update (${version}) was downloaded and will be available next time you open the app.`
console.log(message)
@ -64,6 +80,7 @@ isDesktop() &&
window.electron.appRestart()
},
}),
{ duration: 30000 }
{ duration: 30000, id: AUTO_UPDATER_TOAST_ID }
)
})
}

View File

@ -102,3 +102,6 @@ export const KCL_SAMPLES_MANIFEST_URLS = {
'https://raw.githubusercontent.com/KittyCAD/kcl-samples/main/manifest.json',
localFallback: '/kcl-samples-manifest-fallback.json',
} as const
/** Toast id for the app auto-updater toast */
export const AUTO_UPDATER_TOAST_ID = 'auto-updater-toast'

View File

@ -261,10 +261,30 @@ app.on('ready', () => {
autoUpdater.checkForUpdates().catch(reportRejection)
}, fifteenMinutes)
autoUpdater.on('error', (error) => {
console.error('updater-error', error)
mainWindow?.webContents.send('updater-error', error)
})
autoUpdater.on('update-available', (info) => {
console.log('update-available', info)
})
autoUpdater.prependOnceListener('download-progress', (progress) => {
// For now, we'll send nothing and just start a loading spinner.
// See below for a TODO to send progress data to the renderer.
console.log('update-download-start', {
version: '',
})
mainWindow?.webContents.send('update-download-start', progress)
})
autoUpdater.on('download-progress', (progress) => {
// TODO: in a future PR (https://github.com/KittyCAD/modeling-app/issues/3994)
// send this data to mainWindow to show a progress bar for the download.
console.log('download-progress', progress)
})
autoUpdater.on('update-downloaded', (info) => {
console.log('update-downloaded', info)
mainWindow?.webContents.send('update-downloaded', info.version)

View File

@ -16,8 +16,13 @@ const startDeviceFlow = (host: string): Promise<string> =>
ipcRenderer.invoke('startDeviceFlow', host)
const loginWithDeviceFlow = (): Promise<string> =>
ipcRenderer.invoke('loginWithDeviceFlow')
const onUpdateDownloadStart = (
callback: (value: { version: string }) => void
) => ipcRenderer.on('update-download-start', (_event, value) => callback(value))
const onUpdateDownloaded = (callback: (value: string) => void) =>
ipcRenderer.on('update-downloaded', (_event, value) => callback(value))
const onUpdateError = (callback: (value: Error) => void) =>
ipcRenderer.on('update-error', (_event, value) => callback(value))
const appRestart = () => ipcRenderer.invoke('app.restart')
const isMac = os.platform() === 'darwin'
@ -144,6 +149,8 @@ contextBridge.exposeInMainWorld('electron', {
kittycad,
listMachines,
getMachineApiIp,
onUpdateDownloadStart,
onUpdateDownloaded,
onUpdateError,
appRestart,
})