move config.startTime to app.startTime

This also captures the true start time since it runs before any
require() calls, so the time to require() will be taken into account.
This commit is contained in:
Feross Aboukhadijeh
2016-03-04 16:10:14 -08:00
parent 5f02b73616
commit 82fc6cabe8
4 changed files with 16 additions and 9 deletions

View File

@@ -2,6 +2,5 @@ var path = require('path')
module.exports = {
APP_NAME: 'WebTorrent',
INDEX: 'file://' + path.resolve(__dirname, '..', 'renderer', 'index.html'),
startTime: Date.now()
INDEX: 'file://' + path.resolve(__dirname, '..', 'renderer', 'index.html')
}

View File

@@ -1,9 +1,14 @@
var startTime = Date.now()
var electron = require('electron')
var ipc = require('./ipc')
var menu = require('./menu')
var windows = require('./windows')
var ipc = require('./ipc')
var app = electron.app
app.startTime = startTime
app.on('open-file', onOpen)
app.on('open-url', onOpen)

View File

@@ -1,7 +1,8 @@
var electron = require('electron')
var debug = require('debug')('webtorrent-app:menu')
var windows = require('./windows')
var config = require('./config')
var app = electron.app
function toggleFullScreen () {
debug('toggleFullScreen')
@@ -34,7 +35,7 @@ function toggleDevTools () {
function reloadWindow () {
debug('reloadWindow')
if (windows.main) {
config.startTime = Date.now()
app.startTime = Date.now()
windows.main.webContents.reloadIgnoringCache()
}
}
@@ -191,7 +192,7 @@ function getMenuTemplate () {
]
if (process.platform === 'darwin') {
var name = electron.app.getName()
var name = app.getName()
template.unshift({
label: name,
submenu: [
@@ -230,7 +231,7 @@ function getMenuTemplate () {
{
label: 'Quit',
accelerator: 'Command+Q',
click: function () { electron.app.quit() }
click: function () { app.quit() }
}
]
})

View File

@@ -2,13 +2,15 @@ var electron = require('electron')
var debug = require('debug')('webtorrent-app:windows')
var config = require('./config')
var app = electron.app
var windows = {
main: null,
createMainWindow: createMainWindow
}
var isQuitting = false
electron.app.on('before-quit', function () {
app.on('before-quit', function () {
isQuitting = true
})
@@ -27,7 +29,7 @@ function createMainWindow (menu) {
windows.main.loadURL(config.INDEX)
windows.main.webContents.on('did-finish-load', function () {
setTimeout(function () {
debug('startup time: %sms', Date.now() - config.startTime)
debug('startup time: %sms', Date.now() - app.startTime)
windows.main.show()
}, 50)
})