fix org caching when switching orgs and envs

This commit is contained in:
Ayush Rodrigues
2026-02-28 18:54:32 +00:00
parent ac9d16d5be
commit c2ffe88497
4 changed files with 7 additions and 4 deletions

View File

@@ -120,8 +120,7 @@ export const getFeatureItemDisplay = ({
const intervalDisplay = getIntervalDisplay(item);
if (intervalDisplay) {
secondaryText = intervalDisplay;
} else if (isSingleUseFeature(feature)) {
// Only show "one-off" for single-use features, not continuous use
} else if (isSingleUseFeature(feature) && item.included_usage !== Infinite) {
secondaryText = "one-off";
}
}

View File

@@ -1,4 +1,5 @@
import { type GroupedPermission, groupAndFormatScopes } from "@autumn/shared";
import { clearOrgCache } from "@/hooks/common/useOrg";
import {
Check,
ChevronDown,
@@ -146,7 +147,7 @@ export const Consent = () => {
await authClient.organization.setActive({
organizationId: orgId,
});
// Reload to refresh the page with new org context
clearOrgCache();
window.location.reload();
} catch (_) {
toast.error("Failed to switch organization");

View File

@@ -12,6 +12,7 @@ import {
DropdownMenuContent,
DropdownMenuItem,
} from "@/components/ui/dropdown-menu";
import { clearOrgCache } from "@/hooks/common/useOrg";
import { cn } from "@/lib/utils";
import { envToPath } from "@/utils/genUtils";
import { ExpandedEnvTrigger } from "./env-dropdown/ExpandedEnvTrigger";
@@ -23,6 +24,7 @@ export const useEnvChange = () => {
const handleEnvChange = (targetEnv: AppEnv, reset?: boolean) => {
// Clear all cached query data so it refetches for the new env
queryClient.clear();
clearOrgCache();
// Calculate the new path
const newPath = envToPath(targetEnv, location.pathname);

View File

@@ -26,7 +26,7 @@ import {
} from "@/components/ui/dropdown-menu";
import { Skeleton } from "@/components/ui/skeleton";
import { useTheme } from "@/contexts/ThemeProvider";
import { useOrg } from "@/hooks/common/useOrg";
import { clearOrgCache, useOrg } from "@/hooks/common/useOrg";
import {
authClient,
useListOrganizations,
@@ -247,6 +247,7 @@ export const handleSwitchOrg = async (
organizationId: orgId,
});
clearOrgCache();
window.location.reload();
} catch (error: any) {
toast.error(error.message);