Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Defer loading archives till after the window is shown, which speeds u…
Browse files Browse the repository at this point in the history
…p perceived load time (close #1205)
  • Loading branch information
pfrazee committed Oct 21, 2018
1 parent 5e75c99 commit 3efd9aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/background-process.js
Expand Up @@ -119,6 +119,11 @@ app.on('ready', async function () {
protocol.registerServiceWorkerSchemes(['dat'])
})

app.on('custom-ready-to-show', () => {
// our first window is ready to show, do any additional setup
beakerCore.dat.library.loadSavedArchives()
})

// only run one instance
const isFirstInstance = app.requestSingleInstanceLock()
if (!isFirstInstance) {
Expand Down
9 changes: 8 additions & 1 deletion app/background-process/ui/windows.js
Expand Up @@ -20,6 +20,7 @@ let numActiveWindows = 0
let firstWindow = null
let sessionWatcher = null
let focusedDevtoolsHost
let hasFirstWindowLoaded = false
const BROWSING_SESSION_PATH = './shell-window-state.json'
const ICON_PATH = path.join(__dirname, (process.platform === 'win32') ? './assets/img/logo.ico' : './assets/img/logo.png')
const PRELOAD_PATH = path.join(__dirname, 'shell-window.build.js')
Expand Down Expand Up @@ -143,7 +144,13 @@ export function createShellWindow (windowState) {
icon: ICON_PATH,
show: false // will show when ready
})
win.once('ready-to-show', () => win.show())
win.once('ready-to-show', () => {
win.show()
if (!hasFirstWindowLoaded) {
hasFirstWindowLoaded = true
app.emit('custom-ready-to-show')
}
})
downloads.registerListener(win)
win.loadURL('beaker://shell-window')
sessionWatcher.watchWindow(win, state)
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Expand Up @@ -8,7 +8,7 @@
"copyright": "© 2018, Blue Link Labs",
"main": "background-process.build.js",
"dependencies": {
"@beaker/core": "2.16.3",
"@beaker/core": "2.17.0",
"@beaker/dat-archive-file-diff": "^1.0.0",
"@beaker/electron-localshortcut": "^1.0.0",
"anymatch": "^1.3.2",
Expand Down

0 comments on commit 3efd9aa

Please sign in to comment.