Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b8692bd

Browse files
committed
Prevent state to be toggled whilst a request is pending
1 parent 1f6f9ca commit b8692bd

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/components/views/dialogs/InviteDialog.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -886,19 +886,21 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
886886
};
887887

888888
_toggleMember = (member: Member) => {
889-
let filterText = this.state.filterText;
890-
const targets = this.state.targets.map(t => t); // cheap clone for mutation
891-
const idx = targets.indexOf(member);
892-
if (idx >= 0) {
893-
targets.splice(idx, 1);
894-
} else {
895-
targets.push(member);
896-
filterText = ""; // clear the filter when the user accepts a suggestion
897-
}
898-
this.setState({targets, filterText});
889+
if (!this.state.busy) {
890+
let filterText = this.state.filterText;
891+
const targets = this.state.targets.map(t => t); // cheap clone for mutation
892+
const idx = targets.indexOf(member);
893+
if (idx >= 0) {
894+
targets.splice(idx, 1);
895+
} else {
896+
targets.push(member);
897+
filterText = ""; // clear the filter when the user accepts a suggestion
898+
}
899+
this.setState({targets, filterText});
899900

900-
if (this._editorRef && this._editorRef.current) {
901-
this._editorRef.current.focus();
901+
if (this._editorRef && this._editorRef.current) {
902+
this._editorRef.current.focus();
903+
}
902904
}
903905
};
904906

0 commit comments

Comments
 (0)