Draft
Add confirmation before erasing game history on import or position edit#621
Conversation
…n if game history exists Agent-Logs-Url: https://github.com/benckx/elephantchess/sessions/f9aad699-f886-4ce7-bed7-3e0b7ac83c5b Co-authored-by: benckx <8626080+benckx@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add confirmation when importing moves with existing history
Add confirmation before erasing game history on import or position edit
May 13, 2026
Owner
|
@copilot how could we avoid this copy pasta? const openImportMovesModal = () => {
UI.showModalByName(Modals.IMPORT_MOVES, () => {
new ImportMovesHandler(this.#boardGui, this.#moveTreeWidget);
});
};
if (!this.#moveTreeWidget.isEmpty()) {
const text = buildSimpleSpan('Importing moves will erase the current game history. Continue?');
UI.showConfirmationModal(text, openImportMovesModal, 'import', () => UI.hideModal(null), 'cancel');
} else {
openImportMovesModal();
} |
… confirmation pattern Agent-Logs-Url: https://github.com/benckx/elephantchess/sessions/d9103861-dd07-4c61-a975-f9615cbe5844 Co-authored-by: benckx <8626080+benckx@users.noreply.github.com>
Contributor
Author
... Extracted the pattern into a new UI.openWithConfirmation(
!moveTreeWidget.isEmpty(),
'Importing moves will erase the current game history. Continue?',
'import',
() => UI.showModalByName(Modals.IMPORT_MOVES, () => new ImportMovesHandler(boardGui, moveTreeWidget))
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isEmpty()method toMoveTreeWidgetto expose whether the move tree has movesimportMovesCallbackinanalysis-board.js)move-history-drop-down-menu.js)move-history-drop-down-menu.js)settings-manager.js)UI.openWithConfirmation(shouldConfirm, confirmText, yesButtonText, openFn)helper to eliminate duplicated confirmation pattern across all call sites