Skip to content

Commit

Permalink
fix: backward compatibility (deriv-com#16244)
Browse files Browse the repository at this point in the history
  • Loading branch information
rupato-deriv authored Aug 5, 2024
1 parent aa9919c commit 335f744
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 3 additions & 4 deletions packages/bot-skeleton/src/scratch/backward-compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ export default class BlockConversion {
// For old "market" blocks, move everything in "Trade options" except "DURATION"
// to "Run once at start". Legacy "market" blocks had no such thing as "Run once at start"
// not moving everything would kill Martingale strategies as they'd be reinitialised each run.
const trade_definition_block = this.workspace.getTradeDefinitionBlock();
const has_initialization_block = trade_definition_block.getBlocksInStatement('INITIALIZATION').length > 0;
const trade_definition_block = this.workspace?.getTradeDefinitionBlock();
const has_initialization_block = trade_definition_block?.getBlocksInStatement('INITIALIZATION').length > 0;
if (trade_definition_block) {
trade_definition_block.getBlocksInStatement('SUBMARKET').forEach(block => {
if (
Expand Down Expand Up @@ -505,8 +505,7 @@ export default class BlockConversion {

this.workspace.getAllBlocks(true).forEach(block => {
block.initSvg();
// keep this commneted to fix backward compatibility issue
// block.render();
block.renderEfficiently();
});

this.workspace.cleanUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { localize } from '@deriv/translations';
import { getContractTypeOptions } from '../../../shared';
import { modifyContextMenu } from '../../../utils';

Blockly.Workspace.prototype.getTradeDefinitionBlock = function () {
return this.getAllBlocks(true).find(b => b.type === 'trade_definition');
};

Blockly.Blocks.purchase = {
init() {
this.jsonInit(this.definition());
Expand Down

0 comments on commit 335f744

Please sign in to comment.