fix: clean up neighbors references on state removal (#1304)
Some checks failed
Deploy static content to Pages / deploy (push) Has been cancelled
Code quality / quality (push) Has been cancelled

* fix: clean up neighbors references on state removal

* test: add end-to-end tests for state removal and military regeneration
This commit is contained in:
Marc Emmanuel 2026-02-05 12:40:09 +01:00 committed by GitHub
parent 8ba29b2561
commit f48178a93c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 97 additions and 1 deletions

View file

@ -640,6 +640,12 @@ function stateRemove(stateId) {
});
armies.select("g#army" + stateId).remove();
// clean up neighbors references from other states
pack.states.forEach(state => {
if (!state.i || state.removed || !state.neighbors) return;
state.neighbors = state.neighbors.filter(n => n !== stateId);
});
pack.states[stateId] = {i: stateId, removed: true};
debug.selectAll(".highlight").remove();

View file

@ -991,7 +991,7 @@ function refreshAllEditors() {
// dynamically loaded editors
async function editStates() {
if (customization) return;
const Editor = await import("../dynamic/editors/states-editor.js?v=1.108.1");
const Editor = await import("../dynamic/editors/states-editor.js?v=1.112.1");
Editor.open();
}