Use require so we can import conditionally

This commit is contained in:
David Baker 2016-11-03 15:45:12 +00:00
parent 527c390152
commit ed9c29d365
2 changed files with 7 additions and 13 deletions

View File

@ -20,6 +20,11 @@ limitations under the License.
import VectorBasePlatform from './VectorBasePlatform'; import VectorBasePlatform from './VectorBasePlatform';
import dis from 'matrix-react-sdk/lib/dispatcher'; import dis from 'matrix-react-sdk/lib/dispatcher';
const electron = require('electron');
const remote = electron.remote;
electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
dis.dispatch({ dis.dispatch({
action: 'new_version', action: 'new_version',
@ -29,14 +34,6 @@ function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
}); });
} }
// index.js imports us unconditionally, so we need this check here as well
let electron = null, remote = null;
if (window && window.process && window.process && window.process.type === 'renderer') {
electron = require('electron');
electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
remote = electron.remote;
}
export default class ElectronPlatform extends VectorBasePlatform { export default class ElectronPlatform extends VectorBasePlatform {
setNotificationCount(count: number) { setNotificationCount(count: number) {
super.setNotificationCount(count); super.setNotificationCount(count);

View File

@ -17,16 +17,13 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import ElectronPlatform from './ElectronPlatform';
import WebPlatform from './WebPlatform';
let Platform = null; let Platform = null;
if (window && window.process && window.process && window.process.type === 'renderer') { if (window && window.process && window.process && window.process.type === 'renderer') {
// we're running inside electron // we're running inside electron
Platform = ElectronPlatform; Platform = require('./ElectronPlatform');;
} else { } else {
Platform = WebPlatform; Platform = require('./WebPlatform');;
} }
export default Platform; export default Platform;