Refactor account handling to improve performance
This commit dates the transition from a global user session to individual account handling based on user ID. The transition was made across several components, notably the account settings, icons, and selector. This change improves performance by reducing unnecessary requests and ensures more accurate data handling. The commit also includes some cleanups and minor fixes spread across different components.
This commit is contained in:
@@ -36,6 +36,7 @@ interface AccountSelectorProps {
|
||||
enableTeamCreation: boolean;
|
||||
};
|
||||
|
||||
userId: string;
|
||||
selectedAccount?: string;
|
||||
collapsed?: boolean;
|
||||
className?: string;
|
||||
@@ -49,6 +50,7 @@ export function AccountSelector({
|
||||
accounts,
|
||||
selectedAccount,
|
||||
onAccountChange,
|
||||
userId,
|
||||
className,
|
||||
features = {
|
||||
enableTeamCreation: true,
|
||||
@@ -63,7 +65,7 @@ export function AccountSelector({
|
||||
);
|
||||
|
||||
const { t } = useTranslation('teams');
|
||||
const personalData = usePersonalAccountData();
|
||||
const personalData = usePersonalAccountData(userId);
|
||||
|
||||
useEffect(() => {
|
||||
setValue(selectedAccount ?? PERSONAL_ACCOUNT_SLUG);
|
||||
|
||||
@@ -38,8 +38,7 @@ export function PersonalAccountDropdown({
|
||||
features,
|
||||
account,
|
||||
}: {
|
||||
className?: string;
|
||||
user: User | null;
|
||||
user: User;
|
||||
|
||||
account?: {
|
||||
id: string | null;
|
||||
@@ -48,7 +47,6 @@ export function PersonalAccountDropdown({
|
||||
};
|
||||
|
||||
signOutRequested: () => unknown;
|
||||
showProfileName?: boolean;
|
||||
|
||||
paths: {
|
||||
home: string;
|
||||
@@ -57,8 +55,14 @@ export function PersonalAccountDropdown({
|
||||
features: {
|
||||
enableThemeToggle: boolean;
|
||||
};
|
||||
|
||||
className?: string;
|
||||
showProfileName?: boolean;
|
||||
}) {
|
||||
const { data: personalAccountData } = usePersonalAccountData(account);
|
||||
const { data: personalAccountData } = usePersonalAccountData(
|
||||
user.id,
|
||||
account,
|
||||
);
|
||||
|
||||
const signedInAsLabel = useMemo(() => {
|
||||
const email = user?.email ?? undefined;
|
||||
|
||||
@@ -24,6 +24,8 @@ import { UpdateAccountImageContainer } from './update-account-image-container';
|
||||
|
||||
export function PersonalAccountSettingsContainer(
|
||||
props: React.PropsWithChildren<{
|
||||
userId: string;
|
||||
|
||||
features: {
|
||||
enableAccountDeletion: boolean;
|
||||
};
|
||||
@@ -34,7 +36,7 @@ export function PersonalAccountSettingsContainer(
|
||||
}>,
|
||||
) {
|
||||
const supportsLanguageSelection = useSupportMultiLanguage();
|
||||
const user = usePersonalAccountData();
|
||||
const user = usePersonalAccountData(props.userId);
|
||||
|
||||
if (!user.data || user.isPending) {
|
||||
return <LoadingOverlay fullPage />;
|
||||
|
||||
Reference in New Issue
Block a user