@@ -28,6 +28,7 @@ import {
2828 addTokenIfValid ,
2929} from '../../common/appId' ;
3030import { translate } from '../../common/i18n' ;
31+ import { isEuCountry , showHideEuElements , hasEuAccount } from '../../common/footer-checks' ;
3132import googleDrive from '../../common/integrations/GoogleDrive' ;
3233import { getLanguage } from '../../common/lang' ;
3334import { observer as globalObserver } from '../../common/utils/observer' ;
@@ -43,6 +44,7 @@ import GTM from '../../common/gtm';
4344import { saveBeforeUnload } from './blockly/utils' ;
4445
4546let realityCheckTimeout ;
47+ let chart ;
4648
4749const api = generateLiveApiInstance ( ) ;
4850
@@ -89,8 +91,6 @@ const addBalanceForToken = token => {
8991 } ) ;
9092} ;
9193
92- const chart = new Chart ( api ) ;
93-
9494const tradingView = new TradingView ( ) ;
9595
9696const showRealityCheck = ( ) => {
@@ -186,6 +186,9 @@ const updateTokenList = () => {
186186 loginButton . show ( ) ;
187187 accountList . hide ( ) ;
188188
189+ // If logged out, determine EU based on IP.
190+ isEuCountry ( api ) . then ( isEu => showHideEuElements ( isEu ) ) ;
191+
189192 $ ( '.account-id' )
190193 . removeAttr ( 'value' )
191194 . text ( '' ) ;
@@ -196,13 +199,17 @@ const updateTokenList = () => {
196199 } else {
197200 loginButton . hide ( ) ;
198201 accountList . show ( ) ;
202+
199203 const activeToken = getActiveToken ( tokenList , getStorage ( AppConstants . STORAGE_ACTIVE_TOKEN ) ) ;
204+ showHideEuElements ( hasEuAccount ( tokenList ) ) ;
200205 updateLogo ( activeToken . token ) ;
201206 addBalanceForToken ( activeToken . token ) ;
207+
202208 if ( ! ( 'loginInfo' in activeToken ) ) {
203209 removeAllTokens ( ) ;
204210 updateTokenList ( ) ;
205211 }
212+
206213 tokenList . forEach ( tokenInfo => {
207214 const prefix = isVirtual ( tokenInfo ) ? 'Virtual Account' : `${ tokenInfo . loginInfo . currency } Account` ;
208215 if ( tokenInfo === activeToken ) {
@@ -212,7 +219,9 @@ const updateTokenList = () => {
212219 $ ( '.account-type' ) . text ( `${ prefix } ` ) ;
213220 } else {
214221 $ ( '.login-id-list' ) . append (
215- `<a href="#" value="${ tokenInfo . token } "><li><span>${ prefix } </span><div>${ tokenInfo . accountName } </div></li></a><div class="separator-line-thin-gray"></div>`
222+ `<a href="#" value="${ tokenInfo . token } "><li><span>${ prefix } </span><div>${
223+ tokenInfo . accountName
224+ } </div></li></a><div class="separator-line-thin-gray"></div>`
216225 ) ;
217226 }
218227 } ) ;
@@ -231,7 +240,7 @@ export default class View {
231240 constructor ( ) {
232241 logHandler ( ) ;
233242 this . initPromise = new Promise ( resolve => {
234- updateConfigCurrencies ( ) . then ( ( ) => {
243+ updateConfigCurrencies ( api ) . then ( ( ) => {
235244 symbolPromise . then ( ( ) => {
236245 updateTokenList ( ) ;
237246 this . blockly = new _Blockly ( ) ;
@@ -419,6 +428,10 @@ export default class View {
419428 } ) ;
420429
421430 $ ( '#chartButton' ) . click ( ( ) => {
431+ if ( ! chart ) {
432+ chart = new Chart ( api ) ;
433+ }
434+
422435 chart . open ( ) ;
423436 } ) ;
424437
0 commit comments