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

Commit 4985f63

Browse files
authored
Merge pull request #1 from binary-hamedanchi/mohammad/duplicate_request
Solve duplicate request
2 parents 4676c47 + 3270b66 commit 4985f63

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
@@ -53,7 +53,9 @@ const BinarySocketClass = function() {
5353
'get_settings',
5454
'residence_list',
5555
'landing_company',
56+
'payout_currencies',
5657
];
58+
let sent_requests = [];
5759
const waiting_list = {
5860
items: {},
5961
add : (msg_type, promise_obj) => {
@@ -124,17 +126,25 @@ const BinarySocketClass = function() {
124126
return promise_obj.promise;
125127
};
126128

127-
const send = function(data, force_send) {
129+
const send = function(data, force_send, msg_type) {
128130
const promise_obj = new PromiseClass();
129131

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

139149
if (!data.req_id) {
140150
data.req_id = ++req_id;
@@ -343,6 +353,7 @@ const BinarySocketClass = function() {
343353

344354
binarySocket.onclose = function () {
345355
authorized = false;
356+
sent_requests = [];
346357
clearTimeouts();
347358

348359
if (wrongAppId !== getAppId()) {

0 commit comments

Comments
 (0)