Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port MergeDups goal to use redux-toolkit #2704

Merged
merged 44 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0a811cd
Move changes to state to reducer
jmgrady Oct 5, 2023
1dddb66
Merge tag 'v1.1.3' into redux-toolkit-mergedups
jmgrady Oct 5, 2023
078a726
Complete update of MergeDups actions and reducer
jmgrady Oct 9, 2023
e405255
WIP: Update merge dups tests
jmgrady Oct 11, 2023
0ee2841
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Oct 11, 2023
98100c4
Clear type errors
jmgrady Oct 12, 2023
901283b
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Oct 12, 2023
e46901a
Fix test errors
jmgrady Oct 12, 2023
1d42d5d
Fix lint warning
jmgrady Oct 12, 2023
448a45e
Fix action creation tests
jmgrady Oct 12, 2023
7beffcf
Update MergeDupsActions.test.tsx
jmgrady Oct 18, 2023
79b46a3
[Typescript] Require function return type (#2685)
imnasnainaec Oct 12, 2023
b922d5e
Dependabot updates for 16 October 2023 (#2719)
jmgrady Oct 16, 2023
c6cca9d
[ReviewEntries] Scroll-to-top after changing rows-per-page (#2713)
imnasnainaec Oct 16, 2023
0d0219a
Remove dead code
jmgrady Oct 18, 2023
2beacf0
Create getMergeWords action
jmgrady Oct 20, 2023
b08ff12
Fix test type errors
jmgrady Oct 22, 2023
d21119a
Remove superfluous argument to combineIntoFirstSense
jmgrady Oct 23, 2023
886f515
Clear mergeWords array sooner
jmgrady Oct 23, 2023
f353bb5
Change setWordDataAction to setDataAction to better match original
jmgrady Oct 23, 2023
6c11517
Require sense for convertSenseToMergeTreeSense
jmgrady Oct 23, 2023
0228bdc
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Oct 23, 2023
6c2b208
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Oct 23, 2023
9672315
Add test for deferMerge
jmgrady Oct 24, 2023
f12c2e6
WIP: complete unit tests
jmgrady Oct 30, 2023
04fdedd
Use for...in instead of forEach so that we can continue to next word
jmgrady Oct 30, 2023
b2d7d41
Remove debug printing
jmgrady Oct 31, 2023
486369c
Fix test input data
jmgrady Oct 31, 2023
103edc9
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Oct 31, 2023
1a500fa
Remove commented out tests
jmgrady Oct 31, 2023
f17ef65
Updates from review
jmgrady Nov 1, 2023
0c85093
Extract helper functions from reducer
imnasnainaec Nov 1, 2023
04e26a0
Add tests for definition merges
jmgrady Nov 1, 2023
bd06659
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Nov 1, 2023
70572c9
Rename redux slice for MergeDuplicates
jmgrady Nov 2, 2023
a50f8ab
Remove dead code.
jmgrady Nov 2, 2023
f544781
Remove superfluous await
jmgrady Nov 2, 2023
c7543df
Update from review
jmgrady Nov 2, 2023
9e71bc8
Remove superfluous tests
jmgrady Nov 2, 2023
b96a2da
Change functions to single exit point
jmgrady Nov 3, 2023
4071b20
Remove async
jmgrady Nov 3, 2023
63454e2
Fix input test for moveSenseAction
jmgrady Nov 6, 2023
dc5b778
Remove obsolete comment
jmgrady Nov 6, 2023
ca534c7
Merge branch 'master' into redux-toolkit-mergedups
jmgrady Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function DropWord(props: DropWordProps): ReactElement {

// reset vern if not in vern list
if (treeWord && !verns.includes(treeWord.vern)) {
dispatch(setVern(props.wordId, verns[0] || ""));
dispatch(setVern({ wordId: props.wordId, vern: verns[0] || "" }));
}

return (
Expand All @@ -69,7 +69,12 @@ export default function DropWord(props: DropWordProps): ReactElement {
variant="standard"
value={treeWord.vern}
onChange={(e) =>
dispatch(setVern(props.wordId, e.target.value as string))
dispatch(
setVern({
wordId: props.wordId,
vern: e.target.value as string,
})
)
}
>
{verns.map((vern) => (
Expand All @@ -94,7 +99,7 @@ export default function DropWord(props: DropWordProps): ReactElement {
<FlagButton
flag={treeWord.flag}
updateFlag={(newFlag: Flag) => {
dispatch(flagWord(props.wordId, newFlag));
dispatch(flagWord({ wordId: props.wordId, flag: newFlag }));
}}
buttonId={`word-${props.wordId}-flag`}
/>
Expand Down
20 changes: 16 additions & 4 deletions src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ export default function MergeDragDrop(): ReactElement {
// Case 2a: Cannot merge a protected sense into another sense.
if (sourceId !== res.combine.droppableId) {
// The target sense is in a different word, so move instead of combine.
dispatch(moveSense(senseRef, res.combine.droppableId, 0));
dispatch(
moveSense({
ref: senseRef,
destWordId: res.combine.droppableId,
destOrder: 0,
})
);
}
return;
}
Expand All @@ -66,7 +72,7 @@ export default function MergeDragDrop(): ReactElement {
// Case 2b: If the target is a sidebar sub-sense, it cannot receive a combine.
return;
}
dispatch(combineSense(senseRef, combineRef));
dispatch(combineSense({ src: senseRef, dest: combineRef }));
} else if (res.destination) {
const destId = res.destination.droppableId;
// Case 3: The sense was dropped in a droppable.
Expand All @@ -77,7 +83,13 @@ export default function MergeDragDrop(): ReactElement {
return;
}
// Move the sense to the dest MergeWord.
dispatch(moveSense(senseRef, destId, res.destination.index));
dispatch(
moveSense({
ref: senseRef,
destWordId: destId,
destOrder: res.destination.index,
})
);
} else {
// Case 3b: The source & dest droppables are the same, so we reorder, not move.
const order = res.destination.index;
Expand All @@ -90,7 +102,7 @@ export default function MergeDragDrop(): ReactElement {
// If the sense wasn't moved or was moved within the sidebar above a protected sense, do nothing.
return;
}
dispatch(orderSense(senseRef, order));
dispatch(orderSense({ ref: senseRef, order: order }));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/goals/MergeDuplicates/MergeDupsTreeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export function newMergeTreeWord(
}

export function convertSenseToMergeTreeSense(
sense?: Sense,
sense: Sense,
srcWordId = "",
order = 0
): MergeTreeSense {
return {
...(sense ?? newSense()),
...sense,
srcWordId,
order,
protected: sense?.accessibility === Status.Protected,
Expand Down
Loading
Loading