Page MenuHomePhabricator

[web] Display an error message when adding new user failed
ClosedPublic

Authored by tomek on Jun 27 2022, 8:02 AM.
Tags
None
Referenced Files
F2191497: D4364.diff
Thu, Jul 4, 3:54 PM
Unknown Object (File)
Wed, Jul 3, 8:20 PM
Unknown Object (File)
Fri, Jun 28, 11:19 AM
Unknown Object (File)
Wed, Jun 26, 4:29 AM
Unknown Object (File)
Mon, Jun 24, 10:26 PM
Unknown Object (File)
Sat, Jun 22, 7:38 AM
Unknown Object (File)
Fri, Jun 21, 3:01 AM
Unknown Object (File)
Thu, Jun 20, 3:57 AM
Subscribers

Details

Summary

Catch an exception during relationship update and display error message in case of any failure.

friend_error.png (502×1 px, 47 KB)

Depends on D4315

Test Plan

Modify relationship responders to fail every second time and check if an error is displayed.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek requested review of this revision.Jun 27 2022, 8:07 AM

Nice! Some minor inline feedback, but looks good to me.

web/settings/relationship/add-users-list.react.js
192–203 ↗(On Diff #13841)

Just so I'm clear, this set of lines merges the feedback given in the inline comment from D4315 about wrapping the call to callUpdateRelationships in a try...catch block with the new changes from this diff to set the error message upon an error, right?

If so, maybe the try...catch change should be amended to that diff to address that feedback, and then the only change that needs to be made here is the setErrorMessage call to factor the changesets better. But either way, it is not a big deal.

193 ↗(On Diff #13841)

Is this necessary? The initial value of errorMessage is ''.

201 ↗(On Diff #13841)

Aside: the unknown error message in ThreadSettingsGeneralTab has an underscore:
{F84563}
Not sure why the underscore is there. If it's necessary, though, it should be added in here.

224–227 ↗(On Diff #13841)

I think you can simplify some of the logic here because values are by default undefined in JavaScript and we're just checking to see if errorMessage is falsy or not.

This revision is now accepted and ready to land.Jun 27 2022, 8:40 AM
web/settings/relationship/add-users-list.react.js
192–203 ↗(On Diff #13841)

Yes, you're right - this diff is a response to that feedback. I added a comment there to avoid the confusion.

Regarding updating that diff, I don't think it is a good idea. The goal of that diff is a single, well-defined thing - make sure that we don't close the modal when an error happens. The goal of this diff is to show a message when an error happens. Both goals stand on their own so merging them wouldn't be beneficial.

193 ↗(On Diff #13841)

This handles the case when a user retries a request. I think we don't want to show this error after a button is clicked and before a response is received, just to avoid the user being confused.

201 ↗(On Diff #13841)

There are a lot more places where unknown error is used and I can't think of a good reason why an underscore would be necessary. I guess the reason it is included in ThreadSettingsGeneralTab is that the server returns error codes with underscore and an author wanted to replicate that - but for me it looks like underscores shouldn't be used there.

224–227 ↗(On Diff #13841)

Ok, that makes sense.

web/settings/relationship/add-users-list.react.js
192–203 ↗(On Diff #13841)

Saw your comment right after I posted this, thanks!

The goal of that diff is a single, well-defined thing - make sure that we don't close the modal when an error happens. The goal of this diff is to show a message when an error happens. Both goals stand on their own so merging them wouldn't be beneficial.

👍 Makes sense.

193 ↗(On Diff #13841)

That makes sense! Thanks for clarifying.

Then, shouldn't setErrorMessage('') also be added to ThreadSettingsGeneralTab (above the call to callChangeThreadSettings) as well?
{F84616}

This revision now requires review to proceed.Jun 28 2022, 4:40 AM
web/settings/relationship/add-users-list.react.js
193 ↗(On Diff #13841)

Created a diff with that D4400

This revision is now accepted and ready to land.Jul 1 2022, 12:24 AM