Skip to content

Commit

Permalink
fix: added function to forget history call (deriv-com#12983)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinu-deriv authored Jan 23, 2024
1 parent ef9fc33 commit 36b4b9e
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/bot-skeleton/src/services/api/ticks_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ export default class TicksService {
observe() {
if (api_base.api) {
const subscription = api_base.api.onMessage().subscribe(({ data }) => {
if (data.msg_type === 'history') {
const {
subscription: { id },
} = data;
this.subscriptions = this.subscriptions.set('history', id);
}

if (data.msg_type === 'tick') {
const { tick } = data;
const { symbol, id } = tick;
Expand Down Expand Up @@ -304,11 +311,19 @@ export default class TicksService {
const { stringified_options } = this.ticks_history_promise;
const { symbol = '' } = JSON.parse(stringified_options);
if (symbol) {
this.forget(this.subscriptions.getIn(['tick', symbol]))
.then(res => {
resolve(res);
})
.catch(reject);
if (!this.subscriptions.getIn(['tick', symbol])) {
this.forget(this.subscriptions.get('history'))
.then(res => {
resolve(res);
})
.catch(reject);
} else {
this.forget(this.subscriptions.getIn(['tick', symbol]))
.then(res => {
resolve(res);
})
.catch(reject);
}
} else {
resolve();
}
Expand Down

0 comments on commit 36b4b9e

Please sign in to comment.