Skip to content
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

fix: memory leak on reloading #631

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@ on('initializePluginAsync', ({ name }) => {

console.groupEnd()
})

// Handle `reload` rpc event and reload window
on('reload', () => window.location.reload())
4 changes: 4 additions & 0 deletions app/main.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,7 @@ ipcMain.on('get-window-position', (event, { width, heightWithResults }) => {
})

ipcMain.on('quit', () => app.quit())
ipcMain.on('reload', () => {
app.relaunch()
app.exit()
})
5 changes: 2 additions & 3 deletions app/main/createWindow/AppTray.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ export default class AppTray {
{
label: 'Reload',
click: () => {
mainWindow.reload()
backgroundWindow.reload()
backgroundWindow.hide()
app.relaunch()
app.exit()
}
}]
})
Expand Down
3 changes: 0 additions & 3 deletions app/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@ on('update-downloaded', () => (

// Handle `updateTheme` rpc event and change current theme
on('updateTheme', changeTheme)

// Handle `reload` rpc event and reload window
on('reload', () => location.reload())
13 changes: 8 additions & 5 deletions app/plugins/core/reload/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { send } from 'lib/rpc'
import { ipcRenderer } from 'electron'
import icon from '../icon.png'

const keyword = 'reload'
const title = 'Reload'
const subtitle = 'Reload Cerebro App'
const onSelect = (event) => {
send('reload')
location.reload()
ipcRenderer.send('reload')
event.preventDefault()
}

Expand All @@ -20,8 +19,12 @@ const fn = ({ term, display }) => {
const match = term.match(/^reload\s*/)

if (match) {
display({ icon, title, subtitle, onSelect })
display({
icon, title, subtitle, onSelect
})
}
}

export default { keyword, fn, icon, name: 'Reload' }
export default {
keyword, fn, icon, name: 'Reload'
}