Skip to content

Commit

Permalink
Fix enabling/disabling list refresh race condition (#119)
Browse files Browse the repository at this point in the history
# Fix enabling/disabling list refresh race condition

## ♻️ Current situation & Problem
Closes #115 


## ⚙️ Release Notes 
* Fix enabling/disabling list refresh race condition


## ✅ Testing
Tested manually


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
arkadiuszbachorski authored Feb 4, 2025
1 parent 4c47470 commit 8240a74
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/user/ToggleUserDisabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ export const ToggleUserDisabled = ({ user }: ToggleUserDisabledProps) => {
const isSelf = authUser.auth.uid === user.resourceId;
const userName = getUserName(user);

const handleEnable = () => {
const handleEnable = async () => {
const enableUserPromise = callables.enableUser({ userId: user.resourceId });
toast.promise(enableUserPromise, {
loading: `Enabling ${userName}...`,
success: `${userName} has been enabled.`,
error: `Enabling ${userName} failed. Please try later.`,
});
await enableUserPromise;
void router.invalidate();
};
const handleDisable = () => {

const handleDisable = async () => {
const disableUserPromise = callables.disableUser({
userId: user.resourceId,
});
Expand All @@ -43,6 +45,7 @@ export const ToggleUserDisabled = ({ user }: ToggleUserDisabledProps) => {
success: `${userName} has been disabled.`,
error: `Disabling ${userName} failed. Please try later.`,
});
await disableUserPromise;
void router.invalidate();
};

Expand Down

0 comments on commit 8240a74

Please sign in to comment.