Skip to content

Commit

Permalink
fix senrty freezing action loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Armaldio committed Jul 22, 2024
1 parent 2c8e2b8 commit bf65aa7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 58 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
83 changes: 45 additions & 38 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -26,45 +26,8 @@ if (app.isPackaged) {
Sentry.init({
dsn: "https://[email protected]/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({
Expand Down Expand Up @@ -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')

Expand Down
8 changes: 4 additions & 4 deletions src/main/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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')

Expand All @@ -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')

Expand All @@ -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')

Expand Down
32 changes: 16 additions & 16 deletions src/renderer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bf65aa7

Please sign in to comment.