Skip to content

Commit

Permalink
feat: ⚡ removed core ws from active symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeep-deriv committed Jun 21, 2024
1 parent 1f21f3a commit 1702a71
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/deriv-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Deriv V2</title>
<title>Deriv Bot</title>
</head>
<body class="body">
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/external/bot-skeleton/scratch/dbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DBot {
async initWorkspace(public_path, store, api_helpers_store, is_mobile, is_dark_mode) {
await loadBlockly(is_dark_mode);
const recent_files = await getSavedWorkspaces();
api_base.init();

this.interpreter = Interpreter();
const that = this;
window.Blockly.Blocks.trade_definition_tradetype.onchange = function (event) {
Expand Down
12 changes: 8 additions & 4 deletions src/external/bot-skeleton/services/api/active-symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import PendingPromise from '../../utils/pending-promise';
import { api_base } from './api-base';

export default class ActiveSymbols {
constructor(ws, trading_times) {
constructor(trading_times) {
this.active_symbols = [];
this.disabled_symbols = config.DISABLED_SYMBOLS;
this.disabled_submarkets = config.DISABLED_SUBMARKETS;
this.init_promise = new PendingPromise();
this.is_initialised = false;
this.processed_symbols = {};
this.trading_times = trading_times;
this.ws = ws;
}

async retrieveActiveSymbols(is_forced_update = false) {
Expand All @@ -27,9 +26,14 @@ export default class ActiveSymbols {
}

this.is_initialised = true;
const active_symbols = api_base?.active_symbols ?? [];

this.active_symbols = active_symbols;
if (api_base.has_activeSymbols) {
this.active_symbols = api_base?.active_symbols ?? [];
} else {
await api_base.active_symbols_promise;
this.active_symbols = api_base?.active_symbols ?? [];
}

this.processed_symbols = this.processActiveSymbols();

// TODO: fix need to look into it as the method is not present
Expand Down
8 changes: 5 additions & 3 deletions src/external/bot-skeleton/services/api/api-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class APIBase {
is_stopping = false;
active_symbols = [];

active_symbols_promise = null;

async init(force_update = false) {
if (getLoginId()) {
this.toggleRunButton(true);
Expand All @@ -29,7 +31,7 @@ class APIBase {
} else {
this.api = generateDerivApiInstance();
if (!this.has_activeSymbols) {
this.getActiveSymbols();
this.active_symbols_promise = this.getActiveSymbols();
}
}
}
Expand Down Expand Up @@ -82,7 +84,7 @@ class APIBase {
if (this.has_activeSymbols) {
this.toggleRunButton(false);
} else {
this.getActiveSymbols();
this.getActiveSymbols = this.getActiveSymbols();
}
await this.subscribe();
this.account_info = authorize;
Expand All @@ -101,7 +103,7 @@ class APIBase {
}

getActiveSymbols = async () => {
doUntilDone(() => this.api.send({ active_symbols: 'brief' })).then(({ active_symbols = [] }) => {
await doUntilDone(() => this.api.send({ active_symbols: 'brief' })).then(({ active_symbols = [] }) => {
const pip_sizes = {};
if (active_symbols.length) this.has_activeSymbols = true;
active_symbols.forEach(({ symbol, pip }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/external/bot-skeleton/services/api/api-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ApiHelpers {
constructor(api_helpers_store) {
this.trading_times = new TradingTimes(api_helpers_store);
this.contracts_for = new ContractsFor(api_helpers_store);
this.active_symbols = new ActiveSymbols(api_helpers_store.ws, this.trading_times);
this.active_symbols = new ActiveSymbols(this.trading_times);
this.account_limits = new AccountLimits(api_helpers_store);
}

Expand Down
7 changes: 1 addition & 6 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom/client';

import App from './app/App.tsx';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
ReactDOM.createRoot(document.getElementById('root')!).render(<App />);

0 comments on commit 1702a71

Please sign in to comment.