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

Refactor Workspace Invite Member page #5726

Merged
merged 18 commits into from
Oct 19, 2021

Conversation

parasharrajat
Copy link
Member

@parasharrajat parasharrajat commented Oct 8, 2021

Details

Known issues

Fixed Issues

$ #4775
$ #5723

Tests | QA Steps

  1. Open NewDot.
  2. Go to any workspace from the Settings page.
  3. navigate to Manage members.
  4. Click the Invite button.
  5. Select the user from the list.
  6. Click Invite members should be added to Workspace.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web | Desktop

image

Mobile Web

Screenshot 2021-10-19 04:50:14

iOS

Android

Screenshot 2021-10-19 04:50:14

@parasharrajat parasharrajat marked this pull request as ready for review October 13, 2021 07:05
@parasharrajat parasharrajat requested a review from a team as a code owner October 13, 2021 07:05
@botify botify requested a review from Julesssss October 13, 2021 07:05
@MelvinBot MelvinBot requested review from Julesssss and removed request for a team and Julesssss October 13, 2021 07:05
@parasharrajat
Copy link
Member Author

parasharrajat commented Oct 13, 2021

Heads up: There is an issue with this PR where members are being removed from Onyx as soon as they are added. I am not able to determine the cause of it. Its driving me nuts. Help needed.

I pushed it for review to get more Eyes

@parasharrajat parasharrajat changed the title Refactor Workspace Invite Member page [WIP] Refactor Workspace Invite Member page Oct 13, 2021
@parasharrajat parasharrajat changed the title [WIP] Refactor Workspace Invite Member page Refactor Workspace Invite Member page Oct 15, 2021
@@ -248,7 +248,7 @@ function invite(logins, welcomeNote, policyID) {
policy.alertMessage = '';

// Optimistically add the user to the policy
Onyx.set(key, policy);
Onyx.merge(key, policy);
Copy link
Member Author

@parasharrajat parasharrajat Oct 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make this change otherwise, newly added members were being removed as soon as they were added to Onyx.

I am not sure how to debug the Onyx but I tried debugging the code and somehow internal Keychanged handler is getting old value in the next tick.

@parasharrajat
Copy link
Member Author

@Julesssss Ready for review.

@kidroca
Copy link
Contributor

kidroca commented Oct 15, 2021

@parasharrajat
Here's what happens when Onyx.set was used

  1. When we first click "Invite" an Onyx.merge is triggered from setWorkspaceErrors. It of course uses the policy before we've merged the invited person to it. A merge is pending
  2. Right after the click we update the policy with one more member, this happens before the merged data is saved to storage
  3. And now the merged data (that used the old policy) calls Onyx.set again which causes the bug
1.New.Expensify.-.Google.Chrome.2021-10-15.17-49-48.mp4

This is an issue with how Onyx.merge works and race conditions.
When it happens that both Onyx.set and Onyx.merge are used close in time and it happens that they both modify the same key, Onyx.set is the operation that will complete first and then Onyx.merge would have read an older value and write that to the key

When we always use Onyx.merge there's no such problem, because merges are queued and applied together


There's no single way to fix the race condition at the root

  • Onyx.set usage can be discouraged because of this
  • You can argue that if a set for a key happens it should abort any pending merges for that key. E.g, waiting for the merges to complete and then calling set to write a new value is the same thing but slower. Making merge wait for set to complete (when it's for the same key) is also an option but seems error prone - you can revive values that set wanted to get rid of
  • Merges don't have to read before writing, this is also a performance improvement but it's too big of a change

I think you've found the solution for the problem at hand - use Onyx.merge

For the future we can consider exposing only one way for updating Onyx values so to not cause race conditions and make people wonder should they use set or merge
E.g. Onyx.update(key, value, options)

@kidroca
Copy link
Contributor

kidroca commented Oct 15, 2021

Another take on this problem is why do we store the error state for policy in Onyx? We see that it causes frequent writes to storage and often it writes the same value over and over.

Do we need the error to be persisted so we display it again later, when the user is back at this page or if they restart the app?
I know there's a push towards saving everything in Onyx and I think it's wrong - local component state has no place in persistent storage - for example we're not persisting serachValue or the composer box input for every character that changes. IMO it's ok to store a draft message as this is something you might return to, but to persist an error when we already have component state, and then make every interaction clear it by overwriting storage is like shooting our own foot.

Seeing a code like this reviews that we're not interested in a persisted value and we're using persistent storage for something temporary

 componentDidMount() {
        this.clearErrors();
    }

If we're clearing errors on mount it's obvious we don't care about errors that happened in the past. Then why use persistent storage at all. If Onyx was the only way we dealt with state then I agree that we should always use that, but many components have local state, and this one does too, and if we're not interested in persisted errors, we should just skip persisting them

@parasharrajat
Copy link
Member Author

I agree with @kidroca's point here. But I followed the approach which was already being used in this component and other pages.

So I won't argue the approach. Open to suggestions, if any?

@parasharrajat
Copy link
Member Author

Great Explanation. @kidroca. Thanks for investing time in this. I think we are good for this PR as merge and set have no difference in this scenario.

@Julesssss
Copy link
Contributor

Julesssss commented Oct 18, 2021

Ah, so it was fixes? I've not seen this bot warning before 🤷

My guess is that it's because you have two different 'keywords': $ & fixes. Multiple keywords is usually fine IIRC.

@Julesssss
Copy link
Contributor

Awaiting approval from Design.

@parasharrajat
Copy link
Member Author

@shawnborton Let me know if #5726 (comment) looks good. Please.

@shawnborton
Copy link
Contributor

Looks good, but let's remove the styling and icon from the privacy policy link and just make it blue. Thoughts on that?

Or actually crazy idea, can we just put the privacy policy link after the list of people? This way it's a bit more hidden by default?

@parasharrajat
Copy link
Member Author

Looks good, but let's remove the styling and icon from the privacy policy link and just make it blue. Thoughts on that?

Yup. Will look better and I think Icon can stay as it is informative.

Or actually crazy idea, can we just put the privacy policy link after the list of people? This way it's a bit more hidden by default?

Where exactly? you mean at the end of the user list shown only when scrolled. I doubt that.

@shawnborton
Copy link
Contributor

What makes you say you doubt it? We can always ask our legal team for advice here too.

@parasharrajat
Copy link
Member Author

If the user has about 30 users. He will likely scroll to the end.
Secondly, if a user searches for a user and there is a single match, the link will be brought to the view and I don't feel good about it.

And this is complex to do ATM. 😄 .

@shawnborton
Copy link
Contributor

Got it, that's fair feedback. In the very least, let's see it in just blue and perhaps right-aligned as well. Thanks!

@parasharrajat
Copy link
Member Author

@shawnborton
image

@shawnborton
Copy link
Contributor

Nice, can we see it without the icon as well?

@parasharrajat
Copy link
Member Author

@shawnborton
image

@shawnborton
Copy link
Contributor

Okay sweet, thanks for sharing! I think now that I see it, left-aligned might look better. Then I think it's all good on my end. Thanks Rajat!

@parasharrajat
Copy link
Member Author

parasharrajat commented Oct 18, 2021

No icon? @shawnborton

@shawnborton
Copy link
Contributor

Correct, blue and no icon.

@parasharrajat
Copy link
Member Author

Changes are done as requested. Ready for merge.

@shawnborton
Copy link
Contributor

Nice, I think you just need to update screenshots and then we're good there.

@botify
Copy link

botify commented Oct 18, 2021

❗ Please, do not use Github auto-linking keywords such as these: close, closes, closed, fix, fixes, fixed, resolve, resolves or resolved.

For more details, see the Contributing Guidelines, specifically Submit your pull request for a final review 📖.

2 similar comments
@botify
Copy link

botify commented Oct 18, 2021

❗ Please, do not use Github auto-linking keywords such as these: close, closes, closed, fix, fixes, fixed, resolve, resolves or resolved.

For more details, see the Contributing Guidelines, specifically Submit your pull request for a final review 📖.

@botify
Copy link

botify commented Oct 18, 2021

❗ Please, do not use Github auto-linking keywords such as these: close, closes, closed, fix, fixes, fixed, resolve, resolves or resolved.

For more details, see the Contributing Guidelines, specifically Submit your pull request for a final review 📖.

@Julesssss Julesssss merged commit a5f2739 into Expensify:main Oct 19, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @Julesssss in version: 1.1.8-10 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.1.10-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants