@@ -85,58 +85,62 @@ const MetaTraderUI = (() => {
8585 supported : 0 ,
8686 used : 0 ,
8787 } ;
88+
89+ try {
90+ const trading_servers = State . getResponse ( 'trading_servers' ) ;
91+ trading_servers . forEach ( trading_server => {
92+ // if server is not added to account type, and in accounts_info we are not storing it with server
93+ if ( ! / \d $ / . test ( account_type ) && ! getAccountsInfo ( account_type ) ) {
94+ account_type += `_${ trading_server . id } ` ;
95+ }
96+ const new_account_info = getAccountsInfo ( account_type ) ;
97+ const { market_type, sub_account_type } = new_account_info ;
98+ const { supported_accounts = [ ] } = trading_server ;
99+ const is_server_supported = isSupportedServer ( market_type , sub_account_type , supported_accounts ) ;
100+
101+ if ( is_server_supported ) {
102+ num_servers . supported += 1 ;
103+ const is_used_server = isUsedServer ( is_server_supported , trading_server ) ;
104+
105+ const is_disabled = trading_server . disabled === 1 ;
106+
107+ const input_attributes = {
108+ disabled : is_used_server || is_disabled ,
109+ type : 'radio' ,
110+ name : 'ddl_trade_server' ,
111+ value : trading_server . id ,
112+ ...( trading_server . recommended && ! is_used_server && ! is_disabled && { checked : 'checked' } ) ,
113+ } ;
114+
115+ const { region, sequence } = trading_server . geolocation ;
116+ let label_text = sequence > 1 ? `${ region } ${ sequence } ` : region ;
117+
118+ if ( is_used_server ) {
119+ num_servers . used += 1 ;
120+ label_text += localize ( ' (Region added)' ) ;
121+ } else if ( is_disabled ) {
122+ num_servers . disabled += 1 ;
123+ label_text += localize ( ' (Temporarily unavailable)' ) ;
124+ }
88125
89- State . getResponse ( 'trading_servers' ) . forEach ( trading_server => {
90- // if server is not added to account type, and in accounts_info we are not storing it with server
91- if ( ! / \d $ / . test ( account_type ) && ! getAccountsInfo ( account_type ) ) {
92- account_type += `_${ trading_server . id } ` ;
93- }
94- const new_account_info = getAccountsInfo ( account_type ) ;
95- const { market_type, sub_account_type } = new_account_info ;
96- const { supported_accounts = [ ] } = trading_server ;
97- const is_server_supported = isSupportedServer ( market_type , sub_account_type , supported_accounts ) ;
98-
99- if ( is_server_supported ) {
100- num_servers . supported += 1 ;
101- const is_used_server = isUsedServer ( is_server_supported , trading_server ) ;
102-
103- const is_disabled = trading_server . disabled === 1 ;
104-
105- const input_attributes = {
106- disabled : is_used_server || is_disabled ,
107- type : 'radio' ,
108- name : 'ddl_trade_server' ,
109- value : trading_server . id ,
110- ...( trading_server . recommended && ! is_used_server && ! is_disabled && { checked : 'checked' } ) ,
111- } ;
112-
113- const { region, sequence } = trading_server . geolocation ;
114- let label_text = sequence > 1 ? `${ region } ${ sequence } ` : region ;
115-
116- if ( is_used_server ) {
117- num_servers . used += 1 ;
118- label_text += localize ( ' (Region added)' ) ;
119- } else if ( is_disabled ) {
120- num_servers . disabled += 1 ;
121- label_text += localize ( ' (Temporarily unavailable)' ) ;
126+ $ddl_trade_server
127+ . append (
128+ $ ( '<div />' , { id : trading_server . id , class : 'gr-padding-10 gr-parent' } )
129+ . append ( $ ( '<input />' , input_attributes ) )
130+ . append ( $ ( '<label />' , { htmlFor : trading_server . id } )
131+ . append ( $ ( '<span />' , { text : label_text } ) )
132+ )
133+ ) ;
122134 }
135+ } ) ;
123136
124- $ddl_trade_server
125- . append (
126- $ ( '<div />' , { id : trading_server . id , class : 'gr-padding-10 gr-parent' } )
127- . append ( $ ( '<input />' , input_attributes ) )
128- . append ( $ ( '<label />' , { htmlFor : trading_server . id } )
129- . append ( $ ( '<span />' , { text : label_text } ) )
130- )
131- ) ;
137+ // Check whether any of the servers is checked, if not, check one.
138+ if ( $ddl_trade_server . find ( 'input[checked]' ) . length === 0 ) {
139+ $ddl_trade_server . find ( 'input:not(:disabled):first' ) . attr ( 'checked' , 'checked' ) ;
132140 }
133- } ) ;
134-
135- // Check whether any of the servers is checked, if not, check one.
136- if ( $ddl_trade_server . find ( 'input[checked]' ) . length === 0 ) {
137- $ddl_trade_server . find ( 'input:not(:disabled):first' ) . attr ( 'checked' , 'checked' ) ;
141+ } catch ( e ) {
142+ displayMainMessage ( localize ( 'Our MT5 servers are temporarily unavailable. We\'re working to restore them. Please try again in a few minutes.' ) ) ;
138143 }
139-
140144 return num_servers ;
141145 } ;
142146
0 commit comments