From bf65aa70b22820de9c0ba93d73c6644804e57543 Mon Sep 17 00:00:00 2001 From: Quentin Goinaud Date: Mon, 22 Jul 2024 07:53:08 +0200 Subject: [PATCH] fix senrty freezing action loading --- .vscode/launch.json | 17 +++++++++ src/main.ts | 83 ++++++++++++++++++++++++-------------------- src/main/handlers.ts | 8 ++--- src/renderer/main.ts | 32 ++++++++--------- 4 files changed, 82 insertions(+), 58 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..80a93e0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Main Process", + "type": "node", + "request": "launch", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" + }, + "args" : ["."], + "outputCapture": "std" + } + ] +} diff --git a/src/main.ts b/src/main.ts index 31c1249..d7d5dad 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { app, shell, BrowserWindow, dialog } from 'electron' +import { app, shell, BrowserWindow, dialog, autoUpdater } from 'electron' import { join } from 'path' import { platform } from 'os' import { electronApp, optimizer, is } from '@electron-toolkit/utils' @@ -26,45 +26,8 @@ if (app.isPackaged) { Sentry.init({ dsn: "https://757630879674735027fa5700162253f7@o45694.ingest.us.sentry.io/4507621723144192", }); - - import('update-electron-app').then(autoUpdater => { - autoUpdater.updateElectronApp() - - // autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { - // const dialogOpts: Electron.MessageBoxOptions = { - // type: 'info', - // buttons: ['Restart', 'Later'], - // title: 'Application Update', - // message: process.platform === 'win32' ? releaseNotes : releaseName, - // detail: - // 'A new version has been downloaded. Restart the application to apply the updates.' - // } - - // dialog.showMessageBox(dialogOpts).then((returnValue) => { - // if (returnValue.response === 0) autoUpdater.quitAndInstall() - // }) - // }) - - // autoUpdater.on('error', (message) => { - // console.error('There was a problem updating the application') - // console.error(message) - // }) - - // autoUpdater.on('update-available', (info) => { - // console.log('Found update') - // }) - - // autoUpdater.on('update-not-available', (info) => { - // console.log('No update available') - // }) - - // autoUpdater.on('', (progressObj) => { - // console.log('Download progress: ' + progressObj.percent) - // }) - }) } - function createWindow(): void { // Create the browser window. const mainWindow = new BrowserWindow({ @@ -108,6 +71,50 @@ const { registerBuiltIn } = usePlugins() // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.whenReady().then(async () => { + autoUpdater.setFeedURL({ + serverType: 'default', + url: 'https://github.com/CynToolkit/cyn/releases/latest/download', + headers: { + 'Cache-Control': 'no-cache', + }, + }) + + autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { + const dialogOpts: Electron.MessageBoxOptions = { + type: 'info', + buttons: ['Restart', 'Later'], + title: 'Application Update', + message: process.platform === 'win32' ? releaseNotes : releaseName, + detail: + 'A new version has been downloaded. Restart the application to apply the updates.' + } + + dialog.showMessageBox(dialogOpts).then((returnValue) => { + if (returnValue.response === 0) autoUpdater.quitAndInstall() + }) + }) + + autoUpdater.on('error', (message) => { + console.error('There was a problem updating the application') + console.error(message) + }) + + autoUpdater.on('update-available', (info) => { + console.log('Found update') + }) + + autoUpdater.on('update-not-available', (info) => { + console.log('No update available') + }) + + autoUpdater.on('checking-for-update', (info) => { + console.log('checking-for-update', info) + }) + + console.log('app ready') + autoUpdater.checkForUpdates() + console.log('autoUpdater.getFeedURL()', autoUpdater.getFeedURL()) + // Set app user model id for windows electronApp.setAppUserModelId('com.cyn') diff --git a/src/main/handlers.ts b/src/main/handlers.ts index e530745..5f667fa 100644 --- a/src/main/handlers.ts +++ b/src/main/handlers.ts @@ -58,7 +58,7 @@ export const registerIPCHandlers = () => { console.log('registering ipc handlers') handle('dialog:showOpenDialog', async (event, { value, send }) => { - console.log('event', event) + // console.log('event', event) console.log('value', value) console.log('dialog:showOpenDialog') @@ -81,7 +81,7 @@ export const registerIPCHandlers = () => { }) handle('fs:read', async (event, { value, send }) => { - console.log('event', event) + // console.log('event', event) console.log('value', value) console.log('fs:read') @@ -108,7 +108,7 @@ export const registerIPCHandlers = () => { }) handle('fs:write', async (event, { value, send }) => { - console.log('event', event) + // console.log('event', event) console.log('value', value) console.log('fs:read') @@ -123,7 +123,7 @@ export const registerIPCHandlers = () => { }) handle('dialog:showSaveDialog', async (event, { value, send }) => { - console.log('event', event) + // console.log('event', event) console.log('value', value) console.log('dialog:showSaveDialog') diff --git a/src/renderer/main.ts b/src/renderer/main.ts index 1562510..d0fd7a3 100644 --- a/src/renderer/main.ts +++ b/src/renderer/main.ts @@ -14,7 +14,7 @@ import { definePreset } from '@primevue/themes' import './style/main.scss' import VueDOMPurifyHTML from 'vue-dompurify-html'; -import { init } from "@sentry/electron/renderer"; +// import { init } from "@sentry/electron/renderer"; import { browserTracingIntegration, replayIntegration, init as vueInit } from "@sentry/vue"; const pinia = createPinia() @@ -662,23 +662,23 @@ const CynPreset = definePreset(Aura, { } }) -init({ - vueInit, - integrations: [ - browserTracingIntegration({ router }), - replayIntegration(), - ], +// init({ +// vueInit, +// integrations: [ +// browserTracingIntegration({ router }), +// replayIntegration(), +// ], - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, +// // Set tracesSampleRate to 1.0 to capture 100% +// // of transactions for performance monitoring. +// // We recommend adjusting this value in production +// tracesSampleRate: 1.0, - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, -}); +// // Capture Replay for 10% of all sessions, +// // plus for 100% of sessions with an error +// replaysSessionSampleRate: 0.1, +// replaysOnErrorSampleRate: 1.0, +// }); createApp(Root) .use(router)