Permalink
Browse files

Added offline startup screen

  • Loading branch information...
1 parent c7ccab9 commit 4a4f06a1adfde8b65d804ee175d70719a0e60ee0 @Thomas101 committed Aug 27, 2016
@@ -5,6 +5,12 @@ const path = require('path')
const MailboxesSessionManager = require('./MailboxesSessionManager')
const settingStore = require('../stores/settingStore')
+const MAILBOXES_DIR = path.resolve(path.join(__dirname, '/../../../scenes/mailboxes'))
+const ALLOWED_URLS = new Set([
+ 'file://' + path.join(MAILBOXES_DIR, 'mailboxes.html'),
+ 'file://' + path.join(MAILBOXES_DIR, 'offline.html')
+])
+
class MailboxesWindow extends WMailWindow {
/* ****************************************************************************/
@@ -24,7 +30,7 @@ class MailboxesWindow extends WMailWindow {
}
start (url) {
- super.start('file://' + path.join(__dirname, '/../../../scenes/mailboxes/mailboxes.html'))
+ super.start('file://' + path.join(MAILBOXES_DIR, 'mailboxes.html'))
}
/* ****************************************************************************/
@@ -49,8 +55,10 @@ class MailboxesWindow extends WMailWindow {
super.createWindow.apply(this, Array.from(arguments))
// We're locking on to our window. This stops file drags redirecting the page
- this.window.webContents.on('will-navigate', (evt) => {
- evt.preventDefault()
+ this.window.webContents.on('will-navigate', (evt, url) => {
+ if (!ALLOWED_URLS.has(url)) {
+ evt.preventDefault()
+ }
})
update.checkNow(this.window)
@@ -5,6 +5,11 @@ const mailboxActions = require('./stores/mailbox/mailboxActions')
const settingsActions = require('./stores/settings/settingsActions')
const ipc = window.nativeRequire('electron').ipcRenderer
+// See if we're offline and run a re-direct
+if (window.navigator.onLine === false) {
+ window.location.href = 'offline.html'
+}
+
// Load what we have in the db
mailboxActions.load()
settingsActions.load()

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -35,7 +35,8 @@ const options = {
// Copy our static assets
new CopyWebpackPlugin([
- { from: path.join(__dirname, 'src/mailboxes.html'), to: 'mailboxes.html', force: true }
+ { from: path.join(__dirname, 'src/mailboxes.html'), to: 'mailboxes.html', force: true },
+ { from: path.join(__dirname, 'src/offline.html'), to: 'offline.html', force: true }
], {
ignore: [ '.DS_Store' ]
}),
View
@@ -23,24 +23,16 @@ if (getArg('--fast') !== undefined) {
const task = getArg('--task=', '--task=all').substr(7)
if (task === 'app') {
console.log('[TASK=app]')
- module.exports = [
- require('./src/app/webpack.config.js')
- ]
+ module.exports = [ require('./src/app/webpack.config.js') ]
} else if (task === 'mailboxes') {
console.log('[TASK=mailboxes]')
- module.exports = [
- require('./src/scenes/mailboxes/webpack.config.js')
- ]
+ module.exports = [ require('./src/scenes/mailboxes/webpack.config.js') ]
} else if (task === 'platform') {
console.log('[TASK=platform]')
- module.exports = [
- require('./src/scenes/platform/webpack.config.js')
- ]
+ module.exports = [ require('./src/scenes/platform/webpack.config.js') ]
} else if (task === 'assets') {
console.log('[TASK=assets]')
- module.exports = [
- require('./assets/webpack.config.js')
- ]
+ module.exports = [ require('./assets/webpack.config.js') ]
} else {
console.log('[TASK=all]')
module.exports = [

0 comments on commit 4a4f06a

Please sign in to comment.