-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Unusual remapping renaming behaviour #2425
Conversation
🦋 Changeset detectedLatest commit: e978ced The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR Analysis
PR Feedback
How to useInstructions
|
Commit SHA:98d1fe0a908a36feb6bb425a8a161e019b3c6dd5 Test coverage results 🧪
|
renameGroup(path, newTokenGroupName, type); | ||
remapTokensInGroup({ oldGroupName: `${path}.`, newGroupName: `${newTokenGroupName}.`, type }); | ||
const tokensToRename = await renameGroup(path, newTokenGroupName, type); | ||
remapTokensInGroup({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also have an await in front of it in case someone adds on to this later and wonders why its no executing as expected
src/app/store/useTokens.tsx
Outdated
const remapTokensInGroup = useCallback(async ({ oldGroupName, newGroupName, type }: { oldGroupName: string, newGroupName: string, type: string }) => { | ||
const remapTokensInGroup = useCallback(async ({ | ||
oldGroupName, newGroupName, type, tokensToRename, | ||
}: { oldGroupName: string, newGroupName: string, type: string, tokensToRename: { oldName: string, newName: string }[] }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these an actual type instead of inlining in case something else needs it ?
src/app/store/useTokens.tsx
Outdated
@@ -227,7 +229,9 @@ export default function useTokens() { | |||
}); | |||
if (confirmData && confirmData.result) { | |||
if (Array.isArray(confirmData.data) && confirmData.data.some((data: string) => [UpdateMode.DOCUMENT, UpdateMode.PAGE, UpdateMode.SELECTION].includes(data as UpdateMode))) { | |||
await handleBulkRemap(newGroupName, oldGroupName, confirmData.data[0]); | |||
tokensToRename.forEach(async (tokenToRename) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could cause an issue with race conditions if the bulk remap is slow and something else attempts to change data while its transacting.
Lets change this to
await Promise.all( tokensToRename.map(tokenToRename) => handleBulkRemap(tokenToRename.newName, tokenToRename.oldName, confirmData.data[0]));
)
Tested and confirming that this is fixed @esthercheran |
20231213_034758.mp4