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

Fix remove button remains enabled when removing a user in other device #18934

Merged
merged 4 commits into from
May 15, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ class WorkspaceMembersPage extends React.Component {
this.validate();
}

if (!_.isEqual(prevProps.policyMemberList, this.props.policyMemberList)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need deep comparison here (_.isEqual). Just a shallow comparison will do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s77rt I just updated.

this.setState((prevState) => {
const selectedEmployees = _.filter(prevState.selectedEmployees, (selectedEmployee) => _.has(this.props.policyMemberList, selectedEmployee));
return {
selectedEmployees,
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't you propose to use intersection? Is there something wrong with that?

    this.setState((prevState) => ({
        selectedEmployees: _.intersection(prevState.selectedEmployees, this.props.policyMemberList),
    }));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

selectedEmployees is a string array, but policyMemberList is an object that has key is an email of user

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, this should do it then

    this.setState((prevState) => ({
        selectedEmployees: _.intersection(prevState.selectedEmployees, _.keys(this.props.policyMemberList)),
    }));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main purpose of my solution is the way to fix this issue and this code above is for illustration purposes only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you apply the suggested fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s77rt Sorry, I missed your suggestion above. I will update right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s77rt I just updated, please help to check again.

}

const isReconnecting = prevProps.network.isOffline && !this.props.network.isOffline;
if (!isReconnecting) {
return;
Expand Down