From 2fa7f7931d226d3e8479be3bdc23c5d132500705 Mon Sep 17 00:00:00 2001 From: Priyansh <157942154+Priyansh1547@users.noreply.github.com> Date: Fri, 27 Sep 2024 23:21:19 +0530 Subject: [PATCH] Fix TODO in AppCard.tsx (#16863) --- packages/ui/components/apps/AppCard.tsx | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/ui/components/apps/AppCard.tsx b/packages/ui/components/apps/AppCard.tsx index e9f0742439..81d7243231 100644 --- a/packages/ui/components/apps/AppCard.tsx +++ b/packages/ui/components/apps/AppCard.tsx @@ -42,29 +42,20 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar const mutation = useAddAppMutation(null, { onSuccess: (data) => { if (data?.setupPending) return; - setIsLoading(false); showToast(t("app_successfully_installed"), "success"); }, onError: (error) => { if (error instanceof Error) showToast(error.message || t("app_could_not_be_installed"), "error"); - setIsLoading(false); }, }); const [searchTextIndex, setSearchTextIndex] = useState(undefined); - /** - * @todo Refactor to eliminate the isLoading state by using mutation.isPending directly. - * Currently, the isLoading state is used to manage the loading indicator due to the delay in loading the next page, - * which is caused by heavy queries in getServersideProps. This causes the loader to turn off before the page changes. - */ - const [isLoading, setIsLoading] = useState(mutation.isPending); useEffect(() => { setSearchTextIndex(searchText ? app.name.toLowerCase().indexOf(searchText.toLowerCase()) : undefined); }, [app.name, searchText]); const handleAppInstall = () => { - setIsLoading(true); if (isConferencing(app.categories)) { mutation.mutate({ type: app.type, @@ -154,7 +145,7 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar onClick: () => { handleAppInstall(); }, - loading: isLoading, + loading: mutation.isPending, }; } return ; @@ -176,7 +167,7 @@ export function AppCard({ app, credentials, searchText, userAdminTeams }: AppCar onClick: () => { handleAppInstall(); }, - loading: isLoading, + loading: mutation.isPending, }; } return ;