Skip to content

Commit

Permalink
possible fix for splash screen hang
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsage committed May 21, 2024
1 parent 56cee5c commit 431a557
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/modAssist_window_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,27 +831,20 @@ module.exports.windowLib = class {
* @param {function} openCallback
*/
createMainWindow (openCallback) {
this.win.main = this.createSubWindow('main', { noSelect : false, show : this.#debug, preload : 'mainWindow' })
const doSplashScreen = true

this.win.main = this.createSubWindow('main', { noSelect : false, show : !doSplashScreen, preload : 'mainWindow' })

this.win.main.on('closed', () => {
this.win.main = null
app.quit()
})

if ( !this.#debug ) {
if ( doSplashScreen ) {
this.win.splash = this.createSubWindow('splash', { center : true, fixed : true, frame : false, move : false, useCustomTitle : false })
this.win.splash.loadURL(`file://${path.join(this.#path.render, 'splash.html')}?version=${app.getVersion()}`)

this.win.splash.on('closed', () => { this.win.splash = null })

this.win.main.once('ready-to-show', () => {
setTimeout(() => {
this.win.main.show()
if ( this.isValid('splash') ) {
this.win.splash.destroy()
}
}, 2000)
})
}

this.win.main.loadFile(path.join(this.#path.render, 'main.html'))
Expand All @@ -870,6 +863,14 @@ module.exports.windowLib = class {
})

this.win.main.webContents.on('did-finish-load', () => {
if ( doSplashScreen ) {
setTimeout(() => {
this.win.main.show()
this.safeClose('splash')
this.destroyAndFocus('splash')
}, 2000)
}

const currentFontSize = this.#settings.get('font_size')

this.win.main.webContents.insertCSS(
Expand Down

0 comments on commit 431a557

Please sign in to comment.