fix org caching when switching orgs and envs
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user