0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console): disable unnecessary fetchings when switching tenants (#4123)

This commit is contained in:
Gao Sun 2023-07-05 21:43:46 +08:00 committed by GitHub
parent e8492654e7
commit d6dc308fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,6 @@ import { type TenantInfo, TenantTag } from '@logto/schemas/models';
import { conditionalArray, noop } from '@silverhand/essentials';
import type { ReactNode } from 'react';
import { useCallback, useMemo, createContext, useState } from 'react';
import type { NavigateOptions } from 'react-router-dom';
import { isCloud } from '@/consts/env';
import { getUserTenantId } from '@/consts/tenants';
@ -42,7 +41,7 @@ type Tenants = {
currentTenantStatus: CurrentTenantStatus;
setCurrentTenantStatus: (status: CurrentTenantStatus) => void;
/** Navigate to the given tenant ID. */
navigateTenant: (tenantId: string, options?: NavigateOptions) => void;
navigateTenant: (tenantId: string) => void;
};
const { tenantId, indicator } = defaultManagementApi.resource;
@ -95,8 +94,11 @@ function TenantsProvider({ children }: Props) {
// Use `window.open()` to force page reload since we use `basename` for the router
// which will not re-create the router instance when the URL changes.
window.open(`/${tenantId}`, '_self');
setCurrentTenantId(tenantId);
setCurrentTenantStatus('pending');
// Temporarily disable the current tenant ID change since it will cause some providers
// to re-initialize and re-fetch the data, which is unexpected for now.
// This will be fixed once we merge all routers into one.
// setCurrentTenantId(tenantId);
}, []);
const currentTenant = useMemo(