Skip to content

Commit

Permalink
🐛 Fix: Error rate limit at user directory page (actualbudget#4397)
Browse files Browse the repository at this point in the history
* Error rate limit

* md
  • Loading branch information
lelemm authored Feb 18, 2025
1 parent 3b6c97f commit 7a252d0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,40 @@ type ManageUserDirectoryContentProps = {
function useGetUserDirectoryErrors() {
const { t } = useTranslation();

function getUserDirectoryErrors(reason) {
switch (reason) {
case 'unauthorized':
return t('You are not logged in.');
case 'token-expired':
return t('Login expired, please log in again.');
case 'user-cant-be-empty':
return t(
'Please enter a value for the username; the field cannot be empty.',
);
case 'role-cant-be-empty':
return t('Select a role; the field cannot be empty.');
case 'user-already-exists':
return t(
'The username you entered already exists. Please choose a different username.',
);
case 'not-all-deleted':
return t(
'Not all users were deleted. Check if one of the selected users is the server owner.',
);
case 'role-does-not-exists':
return t(
'Selected role does not exists, possibly a bug? Visit https://actualbudget.org/contact/ for support.',
);
default:
return t(
'An internal error occurred, sorry! Visit https://actualbudget.org/contact/ for support. (ref: {{reason}})',
{ reason },
);
}
}
const getUserDirectoryErrors = useCallback(
reason => {
switch (reason) {
case 'unauthorized':
return t('You are not logged in.');
case 'token-expired':
return t('Login expired, please log in again.');
case 'user-cant-be-empty':
return t(
'Please enter a value for the username; the field cannot be empty.',
);
case 'role-cant-be-empty':
return t('Select a role; the field cannot be empty.');
case 'user-already-exists':
return t(
'The username you entered already exists. Please choose a different username.',
);
case 'not-all-deleted':
return t(
'Not all users were deleted. Check if one of the selected users is the server owner.',
);
case 'role-does-not-exists':
return t(
'Selected role does not exist, possibly a bug? Visit https://actualbudget.org/contact/ for support.',
);
default:
return t(
'An internal error occurred, sorry! Visit https://actualbudget.org/contact/ for support. (ref: {{reason}})',
{ reason },
);
}
},
[t],
);

return { getUserDirectoryErrors };
}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4397.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [lelemm]
---

Fix for User directory page that was calling the api every frame

0 comments on commit 7a252d0

Please sign in to comment.