From 71a649c428dc82cc2d5b47a07ea2c83c17b13291 Mon Sep 17 00:00:00 2001 From: Stefanie Doll Date: Thu, 21 Mar 2019 11:11:14 +0100 Subject: [PATCH] Check if window object exists (#100) * Check if window object exists * brackets for readability * change check to isUndefined() * isUndefined() -> !isUndefined() --- packages/ui-settings/package.json | 1 + packages/ui-settings/src/defaults.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/ui-settings/package.json b/packages/ui-settings/package.json index 4da2eeeb..f7cc3c52 100644 --- a/packages/ui-settings/package.json +++ b/packages/ui-settings/package.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.3.4", + "@polkadot/util": "^0.39.1", "@types/store": "^2.0.1", "store": "^2.0.12" } diff --git a/packages/ui-settings/src/defaults.ts b/packages/ui-settings/src/defaults.ts index 6ad20a34..1198dbba 100644 --- a/packages/ui-settings/src/defaults.ts +++ b/packages/ui-settings/src/defaults.ts @@ -2,10 +2,12 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { isUndefined } from '@polkadot/util'; + import { Options } from './types'; // matches https://polkadot.js.org & https://poc-3.polkadot.io -const isPolkadot = window.location.host.indexOf('polkadot') !== -1; +const isPolkadot = !isUndefined(window) && window.location.host.indexOf('polkadot') !== -1; const WSS_POLKADOT = 'wss://poc3-rpc.polkadot.io/'; const WSS_SUBSTRATE = 'wss://substrate-rpc.parity.io/'; @@ -44,7 +46,7 @@ const UITHEME_DEFAULT = isPolkadot ? 'polkadot' : 'substrate'; -const UIMODE_DEFAULT = !isPolkadot && window.location.host.indexOf('ui-light') !== -1 +const UIMODE_DEFAULT = !isPolkadot && !isUndefined(window) && window.location.host.indexOf('ui-light') !== -1 ? 'light' : 'full';