Skip to content

Commit 12156ab

Browse files
authored
fix: collision on lastTenant key (#3671)
* fix: collision on lastTenant key * chore: lint
1 parent 0e398cd commit 12156ab

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

frontend/app/src/lib/api/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const controlPlaneApi = new ControlPlaneApi({
4848
api.instance.interceptors.request.use(exchangeTokenInterceptor);
4949
cloudApi.instance.interceptors.request.use(exchangeTokenInterceptor);
5050

51-
export const LAST_TENANT_STORAGE_KEY = 'lastTenant';
51+
export const CONTROL_PLANE_TENANT_STORAGE_KEY = 'controlPlaneLastTenant';
5252

5353
type StoredTenantLike = {
5454
metadata?: {
@@ -58,7 +58,7 @@ type StoredTenantLike = {
5858

5959
function readStoredTenantId(): string | null {
6060
try {
61-
const raw = localStorage.getItem(LAST_TENANT_STORAGE_KEY);
61+
const raw = localStorage.getItem(CONTROL_PLANE_TENANT_STORAGE_KEY);
6262
if (!raw) {
6363
return null;
6464
}

frontend/app/src/router.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import api, { TenantMember } from '@/lib/api';
77
import {
88
controlPlaneApi,
99
fetchControlPlaneStatus,
10-
LAST_TENANT_STORAGE_KEY,
10+
CONTROL_PLANE_TENANT_STORAGE_KEY,
1111
} from '@/lib/api/api';
1212
import { exchangeTokenQueryOptions } from '@/lib/api/exchange-token';
1313
import queryClient from '@/query-client';
@@ -221,7 +221,10 @@ const tenantRoute = createRoute({
221221
await api.tenantGet(params.tenant, { xTenantId: params.tenant })
222222
).data;
223223

224-
localStorage.setItem(LAST_TENANT_STORAGE_KEY, JSON.stringify(fullTenant));
224+
localStorage.setItem(
225+
CONTROL_PLANE_TENANT_STORAGE_KEY,
226+
JSON.stringify(fullTenant),
227+
);
225228

226229
// Populate the React Query cache so pages don't re-fetch immediately.
227230
queryClient.setQueryData(['tenant:get', params.tenant], fullTenant);

0 commit comments

Comments
 (0)