From 0b48c897bd7c4792f8e6d4c3f0405c3974589c6f Mon Sep 17 00:00:00 2001 From: Ayrton Sparling Date: Tue, 28 Feb 2017 13:05:32 -0800 Subject: [PATCH] Some more checks --- src/components/Settings.jsx | 7 --- src/index.js | 94 ++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/components/Settings.jsx b/src/components/Settings.jsx index 40fc170..4fac3b3 100644 --- a/src/components/Settings.jsx +++ b/src/components/Settings.jsx @@ -67,13 +67,6 @@ const colorSchemes = [< MenuItem value = "random" key = "random" primaryText = { timeZoneMenuItems.push(); } - const dialogFixedStyles = { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - paddingTop: 0 - }; - class ImageGrid extends React.PureComponent { constructor(props) { super(props); diff --git a/src/index.js b/src/index.js index e9d7be8..c11d4e7 100755 --- a/src/index.js +++ b/src/index.js @@ -7,54 +7,62 @@ import injectTapEventPlugin from 'react-tap-event-plugin'; // http://stackoverflow.com/a/34015469/988941 injectTapEventPlugin(); -setTimeout(() => { - - if (!("lightdm" in window)) { - if (process.env.NODE_ENV !== 'development') { - document.body.innerHTML += '

Lightdm did not load

'; - throw new Error('lightdm did not load in time'); - } else { - const LightDMMock = require("../LightDMMock/mock/LightDMMock.js"); - // const LightDMMock = require("../LightDMMock/src/LightDMMock.js"); - if (!("lightdm" in window)) { - window.lightdm = new LightDMMock(true, 0, false); - window.lightdm.languages.push({code: 'es-ES', name: 'Spanish', territory: null}); - window.lightdm.languages.push({code: 'af-AF', name: 'Africanese', territory: null}); - window.lightdm.languages.push({code: 'ar-SR', name: 'Arabic', territory: null}); - window.lightdm.languages.push({code: 'ja-JP', name: 'Japanese', territory: null}); - window.lightdm.languages.push({code: 'zh-HK', name: 'Chinese', territory: null}); - window.lightdm.languages.push({code: 'he-IS', name: 'Hebrew', territory: null}); - for (let user of lightdm.users) { - user.username = user.name; - } - console.info('Mock users loaded:', lightdm.users) - lightdm.can_shutdown = lightdm.can_restart = lightdm.can_suspend = lightdm.can_hibernate = true; +// Load mock if in development mode +if (!lightdm && process.env.NODE_ENV === 'development') { + const LightDMMock = require("../LightDMMock/mock/LightDMMock.js"); + // const LightDMMock = require("../LightDMMock/src/LightDMMock.js"); + window.lightdm = new LightDMMock(true, 0, false); + window.lightdm.languages.push({code: 'es-ES', name: 'Spanish', territory: null}); + window.lightdm.languages.push({code: 'af-AF', name: 'Africanese', territory: null}); + window.lightdm.languages.push({code: 'ar-SR', name: 'Arabic', territory: null}); + window.lightdm.languages.push({code: 'ja-JP', name: 'Japanese', territory: null}); + window.lightdm.languages.push({code: 'zh-HK', name: 'Chinese', territory: null}); + window.lightdm.languages.push({code: 'he-IS', name: 'Hebrew', territory: null}); + for (let user of lightdm.users) { + user.username = user.name; + } + console.info('Mock users loaded:', lightdm.users) + lightdm.can_shutdown = lightdm.can_restart = lightdm.can_suspend = lightdm.can_hibernate = true; - if (!("config" in window)) { - window.config = { - get_bool: function(key) { - return true; - }, - get_str: function(key) { - return ""; - }, - get_num: function(key) { - return 0; - } - }; - } - if (!("greeterutil" in window)) { - window.greeterutil = { - dirlist: function(dir) { - return undefined; - } - } - } + if (!("config" in window)) { + window.config = { + get_bool: function(key) { + return true; + }, + get_str: function(key) { + return ""; + }, + get_num: function(key) { + return 0; + } + }; + } + if (!("greeterutil" in window)) { + window.greeterutil = { + dirlist: function(dir) { + return undefined; } } } +} + +if (!lightdm || !lightdm.languages) { + const timeout = setTimeout(() => { + clearInterval(interval); + document.body.innerHTML += '

Lightdm did not load

'; + throw new Error('lightdm did not load in time'); + }, 1000); + const interval = setInterval(() => { + + if (lightdm && lightdm.languages) { + clearInterval(interval); + clearTimeout(timeout); + return init(); + } + }, 100); +} else { init(); -}, 10); +} function init() { let Main = require('./components/Main.jsx').default;