fix(gui): fix potencial false window load

This commit is contained in:
Alexey Kasyanchuk 2018-06-18 00:21:35 +03:00
parent d2ad3be4d5
commit 94218b7b74
2 changed files with 610 additions and 605 deletions

View File

@ -152,14 +152,6 @@ app.on("ready", () => {
dbPatcher(() => { dbPatcher(() => {
changeLanguage(appConfig.language, () => setApplicationMenu()) changeLanguage(appConfig.language, () => setApplicationMenu())
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, "app.html"),
protocol: "file:",
slashes: true
})
);
if (env.name === "development") { if (env.name === "development") {
mainWindow.openDevTools(); mainWindow.openDevTools();
} }
@ -240,6 +232,17 @@ app.on("ready", () => {
callback.apply(null, arg) callback.apply(null, arg)
}) })
}, app.getPath("userData"), app.getVersion(), env.name) }, app.getPath("userData"), app.getVersion(), env.name)
// load page only after init app
spider.initialized.then(() => {
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, "app.html"),
protocol: "file:",
slashes: true
})
);
})
}, mainWindow, sphinx) }, mainWindow, sphinx)
}, app.getPath("userData"), () => app.quit()) }, app.getPath("userData"), () => app.quit())
}); });

View File

@ -36,6 +36,8 @@ const torrentClient = require('./torrentClient')
module.exports = function (send, recive, dataDirectory, version, env) module.exports = function (send, recive, dataDirectory, version, env)
{ {
this.initialized = (async () =>
{
let torrentsId = 1; let torrentsId = 1;
let filesId = 1; let filesId = 1;
@ -721,7 +723,7 @@ setInterval(() => {
// load inside api // load inside api
// setup api // setup api
API({ await API({
sphinx, sphinx,
recive, recive,
send, send,
@ -839,6 +841,6 @@ setInterval(() => {
})) }))
}) })
} }
return this
})()
} }