Skip to content

Commit

Permalink
Use new clued entries function
Browse files Browse the repository at this point in the history
  • Loading branch information
legnes committed May 8, 2024
1 parent e09b908 commit 1db6ef9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions app/reducers/builderReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,31 @@ function _builderReducer(
};
}
if (isAddEnumerationsAction(action)) {
// Deep copy clues
const clues = { ...state.clues };
for (const [answer, answerClues] of Object.entries(clues)) {
clues[answer] = answerClues.map((clue) =>
parseClueEnumeration(clue) == null ? `${clue} (${answer.length})` : clue
);
for (const answer in clues) {
const answerClues = clues[answer];
if (answerClues != null) {
clues[answer] = answerClues.slice();
}
}
// Modify only clues that have entries
forEachCluedEntry(
state.grid.sortedEntries,
state.grid.entries,
state.clues,
(_entry, clue, answer, clueIndex) => {
const answerClues = clues[answer];
if (
answerClues != null &&
answerClues.length > clueIndex &&
clue.trim().length > 0 &&
parseClueEnumeration(clue) == null
) {
answerClues[clueIndex] = `${clue} (${answer.length})`;
}
}
);
return { ...state, clues, cluesBackup: { ...state.clues } };
}
if (isRestoreCluesAction(action)) {
Expand Down

0 comments on commit 1db6ef9

Please sign in to comment.