Page MenuHomePhabricator

[web] update add friends modal selection logic
ClosedPublic

Authored by ginsu on Jan 18 2024, 2:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:59 AM
Unknown Object (File)
Thu, Oct 31, 8:58 AM
Unknown Object (File)
Sat, Oct 19, 5:57 PM
Subscribers

Details

Summary

With the new add users modal we now use checkbox ui/ux to select users. This means we can remove the user tags logic we had previously. This diff updates the selection logic and deprecates any unused logic to select a user.

Linear task: https://linear.app/comm/issue/ENG-5957/update-the-ui-of-add-friends-modal

Depends on D10722

Test Plan

Please see the demo video below

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, inka.
ginsu edited the test plan for this revision. (Show Details)
ginsu requested review of this revision.Jan 18 2024, 3:15 PM
web/settings/relationship/add-users-list.react.js
93–97 ↗(On Diff #35862)

This can be simplified

This revision is now accepted and ready to land.Jan 22 2024, 9:37 AM
web/settings/relationship/add-users-list.react.js
93–97 ↗(On Diff #35862)

I'm a little confused by this feedback...

Might be missing something super obvious or wondering if there was a typo and we should simply the following code like this:

setPendingUsersToAdd(pendingUsers => {
  const newPendingUsers = new Set(pendingUsers);
  if (newPendingUsers.has(userID)) {
    newPendingUsers.delete(userID);
    return newPendingUsers;
  }

  newPendingUsers.add(userID);
  return newPendingUsers;
});

cc @ashoat

web/settings/relationship/add-users-list.react.js
93–97 ↗(On Diff #35862)

See here. There's no need to check if the set has the item before deleting it... if it has the item, then deleting it will return true, you will skip adding it. If it doesn't have the item, it won't be deleted, and will return false. Then you will add it.

web/settings/relationship/add-users-list.react.js
93–97 ↗(On Diff #35862)

got it, appreciate the explanation!