Skip to content

Commit 570c716

Browse files
tcnichollongshuicy
andauthored
1082 group is not updated after delete user (#1111)
* after pre commit * does not work * just need dependecy on groupAbout * pre comit * group owner was missing * fixing these to match main, except necessary change. useEffect hook needed to depend on admin mode and groupAbout, so it will change the group members when groupAbout changes. * fix delete group member --------- Co-authored-by: Chen Wang <[email protected]>
1 parent 07e22ea commit 570c716

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

frontend/src/components/groups/Group.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export function Group() {
3030
dispatch(fetchGroupRole(groupId));
3131

3232
const groupAbout = useSelector((state: RootState) => state.group.about);
33+
const deletedGroupMember = useSelector(
34+
(state: RootState) => state.group.deletedGroupMember
35+
);
3336
const role = useSelector((state: RootState) => state.group.role);
3437
const groupCreatorEmail = useSelector(
3538
(state: RootState) => state.group.about.creator
@@ -40,16 +43,10 @@ export function Group() {
4043
const [addMemberModalOpen, setAddMemberModalOpen] = useState(false);
4144
const [deleteGroupConfirmOpen, setDeleteGroupConfirmOpen] = useState(false);
4245

43-
// component did mount
44-
useEffect(() => {
45-
fetchGroupInfo(groupId);
46-
fetchCurrentGroupRole(groupId);
47-
}, []);
48-
4946
useEffect(() => {
5047
fetchGroupInfo(groupId);
5148
fetchCurrentGroupRole(groupId);
52-
}, [adminMode]);
49+
}, [adminMode, deletedGroupMember]);
5350

5451
// Error msg dialog
5552
const [errorOpen, setErrorOpen] = useState(false);

frontend/src/reducers/group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const group = (state = defaultState, action: DataAction) => {
5353
case RECEIVE_GROUP_ROLE:
5454
return Object.assign({}, state, { role: action.role });
5555
case DELETE_GROUP_MEMBER:
56-
return Object.assign({}, state, { deletedGroup: action.about });
56+
return Object.assign({}, state, { deletedGroupMember: action.about });
5757
case UPDATE_GROUP:
5858
return Object.assign({}, state, { about: action.about });
5959
case ADD_GROUP_MEMBER:

0 commit comments

Comments
 (0)