[blockly] Fix persistence block ZDT disconnection (#2306)

Fix so oh_get_persistvalue block does not unnecessarily disconnect the
ZDT input every time a different methodname is selected.

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
pull/2355/head
jimtng 2024-02-14 07:06:39 +10:00 committed by GitHub
parent 76aebaf08e
commit 979bfb1832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 7 deletions

View File

@ -82,15 +82,20 @@ export default function defineOHBlocks_Persistence (f7, isGraalJs, persistenceSe
if (this.getInput('skipPrevious')) {
this.removeInput('skipPrevious')
}
if (this.getInput('dayInfo')) {
this.removeInput('dayInfo')
}
const preposition = (this.methodName === 'historicState') ? 'at' : 'since'
this.appendValueInput('dayInfo')
.appendField(preposition)
.setAlign(Blockly.ALIGN_RIGHT)
.setCheck(['ZonedDateTime'])
if (!this.getInput('dayInfo')) {
this.appendValueInput('dayInfo')
.appendField(preposition, 'preposition')
.setCheck(['ZonedDateTime'])
this.moveInputBefore('dayInfo', 'persistenceName')
} else {
const prepositionField = this.getField('preposition')
if (prepositionField.getText() !== preposition) {
prepositionField.setValue(preposition)
}
}
}
}
}