Page MenuHomePhabricator

[web] dispatch deleteIdentityAction
ClosedPublic

Authored by varun on Dec 15 2023, 3:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 3, 7:49 AM
Unknown Object (File)
Wed, Jul 3, 6:44 AM
Unknown Object (File)
Wed, Jul 3, 6:01 AM
Unknown Object (File)
Tue, Jul 2, 7:34 PM
Unknown Object (File)
Tue, Jul 2, 10:29 AM
Unknown Object (File)
Sun, Jun 30, 11:05 PM
Unknown Object (File)
Sun, Jun 30, 10:14 PM
Unknown Object (File)
Sat, Jun 29, 3:19 PM
Subscribers
None

Details

Summary

dispatch the new action if usingCSAT bool is set to true. also refactored deleteUser method in IdentityServiceClientWrapper as an arrow function to avoid a method-unbinding error.

As in the previous diff in this stack, we're not modifying any reducers yet.

Depends on D10202

Test Plan

tested the following scenarios:

account deletion on native with valid CSAT -> account deleted on keyserver and identity service (also saw DELETE_*_SUCCESS actions in redux devtools)
account deletion on native with invalid CSAT -> account deleted on keyserver and saw DELETE_IDENTITY_ACCOUNT_FAILED in devtools
account deletion on native while disconnected from identity service -> account deleted on keyserver and saw DELETE_IDENTITY_ACCOUNT_FAILED in devtools

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Dec 15 2023, 3:49 AM
tomek requested changes to this revision.Dec 15 2023, 4:05 AM
tomek added inline comments.
web/grpc/identity-service-client-wrapper.js
77–85 ↗(On Diff #34702)

Why is this change needed?

web/settings/account-delete-modal.react.js
31–33 ↗(On Diff #34702)

We have to update this so that we also check the status of deleteIdentityAccountActionTypes

37 ↗(On Diff #34702)

We're going to create a new instance of this object on every render - do we need that, or can we store it e.g. as a ref?

58–70 ↗(On Diff #34702)

We shouldn't popModal in both actions - when the first one finishes, we would pop the modal, and then try to pop the modal again, when the second finishes

81–89 ↗(On Diff #34702)

There's an issue here with handling an error message. Both actions call setErrorMessage(''); which clears the message when they are started. It is possible, that one action will fail and set an error, then the second action will start and clear it. We need to find a way of keeping the errors - e.g. we can clear errors in onDelete and append an error instead of simply setting it. Also, it might be beneficial if the messages were more specific, at least e.g. unknown error while deleting a keyserver.

This revision now requires changes to proceed.Dec 15 2023, 4:05 AM
varun added inline comments.
web/grpc/identity-service-client-wrapper.js
77–85 ↗(On Diff #34702)

without this change, i get a method-unbinding error from flow. if i understand correctly, arrow functions don't have their own this context so the method maintains its binding to the original object, even when it's passed around or detached from its context

keep conditional to avoid unnecessarily rendering div

CI failure is the same one described here... unfortunately it's happening again

web/settings/account-delete-modal.react.js
68–70 ↗(On Diff #35335)

Using <br /> is an anti-pattern. Instead, you should wrap each part in a <p>. You may need to apply some CSS to make it look the way you want to

Please address <br /> usage before landing

web/settings/account-delete-modal.react.js
68–70 ↗(On Diff #35335)

Actually, we should avoid including the <p> if the error message is empty

const keyserverError = keyserverErrorMessage
  ? <p>{keyserverErrorMessage}</p>
  : null;
const identityError = identityErrorMessage
  ? <p>{identityErrorMessage}</p>
  : null;
....
        <div className={css.form_error}>
          {keyserverError}
          {identityError}
        </div>
tomek requested changes to this revision.Jan 8 2024, 3:44 AM
tomek added inline comments.
web/settings/account-delete-modal.react.js
47–49 ↗(On Diff #35335)

We should probably avoid recreating a new object on every render https://react.dev/reference/react/useRef#avoiding-recreating-the-ref-contents

68–70 ↗(On Diff #35335)

We probably also should avoid rendering a <p> with empty content - instead, we should conditionally render it based on the presence of a message

79–82 ↗(On Diff #35335)

If only deleteKeyserverAction call fails, then this code would result in not calling popModal at all. One possible solution might be to await deleteKeyserverAction and deleteIdentityAction promises at the and of onDelete and popModal if any of them throws.

This revision now requires changes to proceed.Jan 8 2024, 3:44 AM
web/settings/account-delete-modal.react.js
79–82 ↗(On Diff #35335)

i think we only want to call popModal if both deleteKeyserverAction and deleteIdentityAction succeed

web/settings/account-delete-modal.react.js
47–52 ↗(On Diff #35406)

followed the example @tomek linked, but wondering if this would be more idiomatic

53–55 ↗(On Diff #35406)

identityServiceClient cannot be null when we call useDeleteIdentityAccount()

web/settings/account-delete-modal.react.js
47–52 ↗(On Diff #35406)

No, you don't want to do this in an effect... then identityServiceClientWrapperRef.current won't be set on the first render

53–55 ↗(On Diff #35406)

I don't understand why you need line 55. const identityServiceClient = identityServiceClientWrapperRef.current should not be nullable... is Flow giving you issues? If so, try an invariant

remove redundant null check

tomek added inline comments.
web/settings/account-delete-modal.react.js
47–52 ↗(On Diff #35406)

but wondering if this would be more idiomatic

It seems like the API of ref is different than the state's, which is surprising. But to make it simpler, we can introduce our hook which exposes a more flexible API. Created a task where we can introduce it. https://linear.app/comm/issue/ENG-6401/introduce-a-hook-that-works-like-useref-and-allows-being-initialized

This revision is now accepted and ready to land.Jan 9 2024, 2:59 AM
web/settings/account-delete-modal.react.js
47–52 ↗(On Diff #35406)

but wondering if this would be more idiomatic

It seems like the API of ref is different than the state's, which is surprising. But to make it simpler, we can introduce our hook which exposes a more flexible API. Created a task where we can introduce it. https://linear.app/comm/issue/ENG-6401/introduce-a-hook-that-works-like-useref-and-allows-being-initialized

We can make this even better by introducing a context and moving the auth API to it. Created a task tracing it https://linear.app/comm/issue/ENG-6404/move-identity-client-to-a-context.

This revision was landed with ongoing or failed builds.Jan 9 2024, 9:14 PM
This revision was automatically updated to reflect the committed changes.