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

Commit 3270b66

Browse files
Solve duplicate request
1 parent 239a188 commit 3270b66

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/javascript/binary/websocket_pages/mb_trade/mb_symbols.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const MBSymbols = (function () {
5757
} else if (website_status.website_status.clients_country === 'jp' || getLanguage() === 'JA') {
5858
req.landing_company = 'japan';
5959
}
60-
BinarySocket.send(req);
60+
BinarySocket.send(req, false, 'active_symbols');
6161
need_page_update = update;
6262
});
6363
};

src/javascript/binary/websocket_pages/socket.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ const BinarySocketClass = function() {
5454
'get_settings',
5555
'residence_list',
5656
'landing_company',
57+
'payout_currencies',
5758
];
59+
let sent_requests = [];
5860
const waiting_list = {
5961
items: {},
6062
add : (msg_type, promise_obj) => {
@@ -125,17 +127,25 @@ const BinarySocketClass = function() {
125127
return promise_obj.promise;
126128
};
127129

128-
const send = function(data, force_send) {
130+
const send = function(data, force_send, msg_type) {
129131
const promise_obj = new PromiseClass();
130132

131-
if (!force_send) {
132-
const msg_type = no_duplicate_requests.find(c => c in data);
133+
msg_type = msg_type || no_duplicate_requests.find(c => c in data);
134+
if (!force_send && msg_type) {
133135
const last_response = State.get(['response', msg_type]);
134136
if (last_response) {
135137
promise_obj.resolve(last_response);
136138
return promise_obj.promise;
139+
} else if (sent_requests.indexOf(msg_type) >= 0) {
140+
return wait(msg_type).then((response) => {
141+
promise_obj.resolve(response);
142+
return promise_obj.promise;
143+
});
137144
}
138145
}
146+
if (msg_type) {
147+
sent_requests.push(msg_type);
148+
}
139149

140150
if (!data.req_id) {
141151
data.req_id = ++req_id;
@@ -345,6 +355,7 @@ const BinarySocketClass = function() {
345355

346356
binarySocket.onclose = function () {
347357
authorized = false;
358+
sent_requests = [];
348359
clearTimeouts();
349360

350361
if (!manualClosed && wrongAppId !== getAppId()) {

0 commit comments

Comments
 (0)