Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit e7c9d56

Browse files
fix_mlt_and_uk_market
1 parent 8446612 commit e7c9d56

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/javascript/_common/base/client_base.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ const ClientBase = (() => {
403403
return options_blocked_countries.includes(country);
404404
};
405405

406+
const isMalta = () => {
407+
const malta_countries = ['at', 'be', 'bg', 'cy', 'cz', 'dk', 'ee', 'fi', 'hr', 'hu', 'ie', 'lt', 'lv', 'nl', 'pl', 'pt', 'ro', 'se', 'si', 'sk'];
408+
const country = State.getResponse('authorize.country');
409+
410+
return malta_countries.includes(country);
411+
};
412+
406413
return {
407414
init,
408415
isLoggedIn,
@@ -433,6 +440,7 @@ const ClientBase = (() => {
433440
canTransferFunds,
434441
hasSvgAccount,
435442
canChangeCurrency,
443+
isMalta,
436444
};
437445
})();
438446

src/javascript/app/pages/trade/markets.jsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Defaults from './defaults';
66
import { sortSubmarket, getAvailableUnderlyings } from '../../common/active_symbols';
77
import { getElementById } from '../../../_common/common_functions';
88
import { localize } from '../../../_common/localize';
9+
import Client from '../../base/client';
10+
import { State } from '../../../_common/storage';
911

1012
function scrollToPosition (element, to, duration) {
1113
const requestAnimationFrame = window.requestAnimationFrame ||
@@ -69,7 +71,9 @@ class Markets extends React.Component {
6971
constructor (props) {
7072
super(props);
7173
let market_symbol = Defaults.get('market');
72-
74+
let final_markets_arr,
75+
final_market_obj;
76+
7377
const market_list = Symbols.markets();
7478
this.markets = getAvailableUnderlyings(market_list);
7579

@@ -80,9 +84,19 @@ class Markets extends React.Component {
8084
underlying_symbol = Object.keys(this.markets[market_symbol].submarkets[submarket].symbols).sort()[0];
8185
}
8286
const is_not_crypto = symbol => !/^(cry|JD)/i.test(symbol);
87+
const is_synthetic = symbol => /^(synthetic)/i.test(symbol);
88+
const is_uk = State.getResponse('authorize.country') === 'gb';
8389
const market_arr = Object.entries(this.markets).sort((a, b) => sortSubmarket(a[0], b[0]));
84-
const non_crypto_markets_arr = market_arr.filter(market => is_not_crypto(market));
85-
this.markets_all = non_crypto_markets_arr.slice();
90+
final_markets_arr = market_arr.filter(market => is_not_crypto(market));
91+
final_market_obj = Object.fromEntries(final_markets_arr);
92+
if ((Client.isMalta() || is_uk) && Client.getAccountOfType('virtual')) {
93+
final_markets_arr = market_arr.filter(market => is_synthetic(market));
94+
final_market_obj = Object.fromEntries(final_markets_arr);
95+
market_symbol = Object.keys(final_market_obj)[0];
96+
const submarket = Object.keys(final_market_obj[market_symbol].submarkets).sort(sortSubmarket)[0];
97+
underlying_symbol = Object.keys(final_market_obj[market_symbol].submarkets[submarket].symbols).sort()[0];
98+
}
99+
this.markets_all = final_markets_arr.slice();
86100
if (!(market_symbol in this.markets)) {
87101
market_symbol = Object.keys(this.markets).find(m => this.markets[m].submarkets[market_symbol]);
88102
Defaults.set('market', market_symbol);
@@ -93,13 +107,13 @@ class Markets extends React.Component {
93107
open : false,
94108
market: {
95109
symbol: market_symbol,
96-
name : this.markets[market_symbol].name,
110+
name : final_market_obj[market_symbol].name,
97111
},
98112
underlying: {
99113
symbol: underlying_symbol,
100114
name : this.underlyings[underlying_symbol],
101115
},
102-
markets : non_crypto_markets_arr,
116+
markets : final_markets_arr,
103117
active_market : market_symbol,
104118
query : '',
105119
open_dropdown_scroll_id: 0,

0 commit comments

Comments
 (0)