-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix/32230: Update recently used tag and category when editing request #32467
Conversation
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${iouReport.policyID}`, | ||
value: optimisticPolicyRecentlyUsedTags, | ||
}); | ||
} |
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.
is there a way to DRY those LOC @DylanDylann?
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.
@hoangzinh We can create new function called createOptimisticPolicyRecentlyUsedTagOrCategory
and update like this
if (_.has(transactionChanges, 'category')) {
optimisticData.push(createOptimisticPolicyRecentlyUsedTagOrCategory());
}
}
But I don't think It helps to dry code lots. What do you think ?
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.
Hmm, let's leave it as it is. It's not a big problem for me. Let me complete the checklist and wait opinion from Internal engineer.
const optimisticPolicyRecentlyUsedTags = Policy.buildOptimisticPolicyRecentlyUsedTags(iouReport.policyID, transactionChanges.tag); | ||
if (!_.isEmpty(optimisticPolicyRecentlyUsedTags)) { | ||
optimisticData.push({ | ||
onyxMethod: Onyx.METHOD.MERGE, |
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.
should we use the method "SET" here? For POLICY_RECENTLY_USED_CATEGORIES above, it's using method SET, but here it's using method MERGE. I found it's inconsistency.
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.
@hoangzinh I agree with you at this point. But currently we use MERGE method for tag in other places
Line 187 in 18d4b9b
onyxMethod: Onyx.METHOD.MERGE, |
Line 1875 in 18d4b9b
onyxMethod: Onyx.METHOD.MERGE, |
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.
It looks like MERGE or SET is same if it's an array https://github.com/Expensify/react-native-onyx#should-i-use-merge-or-set-or-both, nvm.
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.
@hoangzinh Do you mean that we should update to use SET in all places ?
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.
I think so, it's stated here
Use set() when you need to completely reset an object or array of data
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.
@hoangzinh Updated
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.
i had this exact question!
The only thing though is that I think these all either need to be SET
or all need to MERGE
per
For this reason, it is usually preferable to use one or the other, but not both.
And even more fun once you look at buildOptimisticPolicyRecentlyUsedCategories
returns an array
and buildOptimisticPolicyRecentlyUsedTags
returns an object
So I think for calls to set the recently used categories we should use SET
everywhere as noted
You should avoid arrays as much as possible. They do not work well with merge() because it can't update a single element in an array, it must always set the entire array each time.
And for recently used tags we should use MERGE
everywhere since those are objects.
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-12-09.at.21.47.52.-.android.mp4Android: mWeb ChromeScreen.Recording.2023-12-09.at.21.51.07.-.android.chrome.moviOS: NativeScreen.Recording.2023-12-09.at.21.53.29.-.ios.mp4iOS: mWeb SafariScreen.Recording.2023-12-09.at.21.56.05.-.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2023-12-09.at.21.40.23.-.web.movMacOS: DesktopScreen.Recording.2023-12-09.at.21.42.33.-.desktop.mp4 |
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.
I think we need to update OnyxMethods per #32467 (comment)
@bondydaa Updated, please help to check again |
@hoangzinh Could you help to re-check and approve again? Then @bondydaa will merge this PR |
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.
LGTM
@bondydaa Please help to merge this PR when you have a chance. Thanks for all |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/bondydaa in version: 1.4.13-0 🚀
|
🚀 Deployed to staging by https://github.com/bondydaa in version: 1.4.13-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.4.13-8 🚀
|
Details
Update recently used tag and category when editing request
Fixed Issues
$ #32230
PROPOSAL: #32230 (comment)
Tests
Offline tests
same above
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screencast.from.06-12-2023.18.06.48.webm
Android: mWeb Chrome
Screencast.from.06-12-2023.18.14.46.webm
iOS: Native
ios.mp4
iOS: mWeb Safari
Screen.Recording.2023-12-05.at.12.40.36.mov
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
de.mp4