Skip to content

Commit 0061c9d

Browse files
committed
Fixed the undo problem caused by the bw compat code
1 parent 1c77e23 commit 0061c9d

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

src/botPage/view/blockly/blocks/trade/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { setBlockTextColor, findTopParentBlock, deleteBlockIfExists } from '../.
1010

1111
const backwardCompatibility = (block) => {
1212
setTimeout(() => {
13+
Blockly.Events.recordUndo = false;
1314
const parent = block.getParent();
1415
if (parent) {
1516
const submarketConnection = block.getInput('SUBMARKET').connection;
@@ -21,6 +22,7 @@ const backwardCompatibility = (block) => {
2122
submarketConnection.connect((ancestor || parent).previousConnection);
2223
}
2324
block.setPreviousStatement(false);
25+
Blockly.Events.recordUndo = true;
2426
}, 0);
2527
};
2628

src/botPage/view/blockly/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export default class _Blockly {
124124
}
125125
}
126126
cleanUp() {
127+
Blockly.Events.recordUndo = false;
127128
Blockly.mainWorkspace.cleanUp();
129+
Blockly.Events.recordUndo = true;
128130
}
129131
xmlToStr(xml) {
130132
const serializer = new XMLSerializer();
@@ -185,8 +187,10 @@ export default class _Blockly {
185187
return Blockly.Xml.domToBlock(blockXml, Blockly.mainWorkspace);
186188
}
187189
resetWorkspace() {
190+
Blockly.Events.recordUndo = false;
188191
Blockly.mainWorkspace.clear();
189192
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(this.blocksXmlStr), Blockly.mainWorkspace);
193+
Blockly.Events.recordUndo = true;
190194
}
191195
loadWorkspace(xml) {
192196
Blockly.mainWorkspace.clear();
@@ -224,6 +228,7 @@ export default class _Blockly {
224228
observer.emit('ui.log.error',
225229
translator.translateText('Unrecognized file format.'));
226230
} else {
231+
Blockly.Events.recordUndo = false;
227232
try {
228233
const xml = Blockly.Xml.textToDom(blockStr);
229234
if (xml.hasAttribute('collection') && xml.getAttribute('collection') === 'true') {
@@ -241,6 +246,7 @@ export default class _Blockly {
241246
translator.translateText('Unrecognized file format.'));
242247
}
243248
}
249+
Blockly.Events.recordUndo = true;
244250
}
245251
}
246252
save(filename, collection) {

src/botPage/view/blockly/relationChecker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export const submarket = (blockObj, ev) => {
124124
observer.emit('ui.log.warn',
125125
translator.translateText('Submarket blocks can only accept trade type blocks'));
126126
for (const child of Array.prototype.slice.apply(blockObj.childBlocks_)) {
127-
disable(child);
127+
Blockly.Events.recordUndo = false;
128+
child.unplug();
129+
Blockly.Events.recordUndo = true;
128130
}
129131
} else if (blockObj.childBlocks_.length > 0) {
130132
condition(blockObj.childBlocks_[0], ev, true);

src/botPage/view/blockly/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@ import { translator } from '../../../common/translator';
66
const purchaseChoices = [[translator.translateText('Click to select'), '']];
77

88
export const deleteBlockIfExists = (block) => {
9+
Blockly.Events.recordUndo = false;
910
for (const mainBlock of Blockly.mainWorkspace.getTopBlocks()) {
1011
if (!block.isInFlyout && mainBlock.id !== block.id && mainBlock.type === block.type) {
1112
block.dispose();
1213
return true;
1314
}
1415
}
16+
Blockly.Events.recordUndo = true;
1517
return false;
1618
};
1719

1820
export const setBlockTextColor = (block) => {
21+
Blockly.Events.recordUndo = false;
1922
const field = block.getField();
2023
if (field) {
2124
field.getSvgRoot()
2225
.style.setProperty('fill', 'white', 'important');
2326
}
27+
Blockly.Events.recordUndo = true;
2428
};
2529

2630
export const configMainBlock = (ev, type) => {
@@ -109,6 +113,7 @@ export const addPurchaseOptions = (submarket) => {
109113
});
110114
const purchases = Blockly.mainWorkspace.getAllBlocks()
111115
.filter((r) => (['purchase', 'payout', 'ask_price'].indexOf(r.type) >= 0));
116+
Blockly.Events.recordUndo = false;
112117
for (const purchase of purchases) {
113118
const value = purchase.getField('PURCHASE_LIST')
114119
.getValue();
@@ -126,6 +131,7 @@ export const addPurchaseOptions = (submarket) => {
126131
.setText(firstOption.name);
127132
}
128133
}
134+
Blockly.Events.recordUndo = true;
129135
}
130136
};
131137

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy