Skip to content

Commit

Permalink
remove now unnecessary user loading indicatort log (#3333)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx authored Dec 4, 2024
1 parent 14863bd commit 4f99412
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 49 deletions.
6 changes: 1 addition & 5 deletions web/src/app/admin/assistants/PersonaTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function PersonaTypeDisplay({ persona }: { persona: Persona }) {
export function PersonasTable() {
const router = useRouter();
const { popup, setPopup } = usePopup();
const { refreshUser, isLoadingUser, isAdmin } = useUser();
const { refreshUser, isAdmin } = useUser();
const {
allAssistants: assistants,
refreshAssistants,
Expand Down Expand Up @@ -98,10 +98,6 @@ export function PersonasTable() {
await refreshUser();
};

if (isLoadingUser) {
return <></>;
}

return (
<div>
{popup}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GoogleDriveConfig } from "@/lib/connectors/connectors";
import { useUser } from "@/components/user/UserProvider";

const GDriveMain = ({}: {}) => {
const { isLoadingUser, isAdmin, user } = useUser();
const { isAdmin, user } = useUser();

const {
data: appCredentialData,
Expand Down Expand Up @@ -63,10 +63,6 @@ const GDriveMain = ({}: {}) => {
serviceAccountKeyData ||
(isServiceAccountKeyError && isServiceAccountKeyError.status === 404);

if (isLoadingUser) {
return <></>;
}

if (
(!appCredentialSuccessfullyFetched && isAppCredentialLoading) ||
(!serviceAccountKeySuccessfullyFetched && isServiceAccountKeyLoading) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { GmailConfig } from "@/lib/connectors/connectors";
import { useUser } from "@/components/user/UserProvider";

export const GmailMain = () => {
const { isLoadingUser, isAdmin, user } = useUser();
const { isAdmin, user } = useUser();

const {
data: appCredentialData,
Expand Down Expand Up @@ -60,10 +60,6 @@ export const GmailMain = () => {
serviceAccountKeyData ||
(isServiceAccountKeyError && isServiceAccountKeyError.status === 404);

if (isLoadingUser) {
return <></>;
}

if (
(!appCredentialSuccessfullyFetched && isAppCredentialLoading) ||
(!serviceAccountKeySuccessfullyFetched && isServiceAccountKeyLoading) ||
Expand Down
6 changes: 1 addition & 5 deletions web/src/app/auth/impersonate/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ const ImpersonateSchema = Yup.object().shape({

export default function ImpersonatePage() {
const router = useRouter();
const { user, isLoadingUser, isCloudSuperuser } = useUser();
const { user, isCloudSuperuser } = useUser();
const { popup, setPopup } = usePopup();

if (isLoadingUser) {
return null;
}

if (!user) {
redirect("/auth/login");
}
Expand Down
6 changes: 2 additions & 4 deletions web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function ChatPage({
!shouldShowWelcomeModal
);

const { user, isAdmin, isLoadingUser } = useUser();
const { user, isAdmin } = useUser();
const slackChatId = searchParams.get("slackChatId");
const existingChatIdRaw = searchParams.get("chatId");
const [sendOnLoad, setSendOnLoad] = useState<string | null>(
Expand Down Expand Up @@ -2199,9 +2199,7 @@ export function ChatPage({
/>
)}

{documentSidebarInitialWidth !== undefined &&
isReady &&
!isLoadingUser ? (
{documentSidebarInitialWidth !== undefined && isReady ? (
<Dropzone onDrop={handleImageUpload} noClick>
{({ getRootProps }) => (
<div className="flex h-full w-full">
Expand Down
5 changes: 1 addition & 4 deletions web/src/app/ee/admin/groups/[groupId]/GroupDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ export const GroupDisplay = ({
const [addConnectorFormVisible, setAddConnectorFormVisible] = useState(false);
const [addRateLimitFormVisible, setAddRateLimitFormVisible] = useState(false);

const { isLoadingUser, isAdmin } = useUser();
if (isLoadingUser) {
return <></>;
}
const { isAdmin } = useUser();

const handlePopup = (message: string, type: "success" | "error") => {
setPopup({ message, type });
Expand Down
5 changes: 1 addition & 4 deletions web/src/app/ee/admin/groups/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const Main = () => {
error: usersError,
} = useUsers();

const { isLoadingUser, isAdmin } = useUser();
if (isLoadingUser) {
return <></>;
}
const { isAdmin } = useUser();

if (isLoading || isCCPairsLoading || userIsLoading) {
return <ThreeDotsLoader />;
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/IsPublicGroupSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
enforceGroupSelection?: boolean;
}) => {
const { data: userGroups, isLoading: userGroupsIsLoading } = useUserGroups();
const { isAdmin, user, isLoadingUser, isCurator } = useUser();
const { isAdmin, user, isCurator } = useUser();
const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();
const [shouldHideContent, setShouldHideContent] = useState(false);

Expand All @@ -52,7 +52,7 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
}
}, [user, userGroups, isPaidEnterpriseFeaturesEnabled]);

if (isLoadingUser || userGroupsIsLoading) {
if (userGroupsIsLoading) {
return <div>Loading...</div>;
}
if (!isPaidEnterpriseFeaturesEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/admin/connectors/AccessTypeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function AccessTypeForm({

const isPaidEnterpriseEnabled = usePaidEnterpriseFeaturesEnabled();
const isAutoSyncSupported = isValidAutoSyncSource(connector);
const { isLoadingUser, isAdmin } = useUser();
const { isAdmin } = useUser();

useEffect(() => {
if (!isPaidEnterpriseEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function AccessTypeGroupSelector({
connector: ConfigurableSources;
}) {
const { data: userGroups, isLoading: userGroupsIsLoading } = useUserGroups();
const { isAdmin, user, isLoadingUser, isCurator } = useUser();
const { isAdmin, user, isCurator } = useUser();
const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();
const [shouldHideContent, setShouldHideContent] = useState(false);
const isAutoSyncSupported = isValidAutoSyncSource(connector);
Expand Down Expand Up @@ -77,7 +77,7 @@ export function AccessTypeGroupSelector({
isPaidEnterpriseFeaturesEnabled,
]);

if (isLoadingUser || userGroupsIsLoading) {
if (userGroupsIsLoading) {
return <div>Loading...</div>;
}
if (!isPaidEnterpriseFeaturesEnabled) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/context/AssistantsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const AssistantsProvider: React.FC<{
const [assistants, setAssistants] = useState<Persona[]>(
initialAssistants || []
);
const { user, isLoadingUser, isAdmin, isCurator } = useUser();
const { user, isAdmin, isCurator } = useUser();
const [editablePersonas, setEditablePersonas] = useState<Persona[]>([]);
const [allAssistants, setAllAssistants] = useState<Persona[]>([]);

Expand Down Expand Up @@ -194,7 +194,7 @@ export const AssistantsProvider: React.FC<{
finalAssistants,
ownedButHiddenAssistants,
};
}, [user, assistants, isLoadingUser]);
}, [user, assistants]);

return (
<AssistantsContext.Provider
Expand Down
5 changes: 1 addition & 4 deletions web/src/components/credentials/actions/CreateCredential.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ export default function CreateCredential({
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();

const { isLoadingUser, isAdmin } = useUser();
if (isLoadingUser) {
return <></>;
}
const { isAdmin } = useUser();

const handleSubmit = async (
values: formType,
Expand Down
6 changes: 0 additions & 6 deletions web/src/components/user/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { usePostHog } from "posthog-js/react";

interface UserContextType {
user: User | null;
isLoadingUser: boolean;
isAdmin: boolean;
isCurator: boolean;
refreshUser: () => Promise<void>;
Expand All @@ -25,7 +24,6 @@ export function UserProvider({
user: User | null;
}) {
const [upToDateUser, setUpToDateUser] = useState<User | null>(user);
const [isLoadingUser, setIsLoadingUser] = useState(false);

const posthog = usePostHog();

Expand All @@ -47,13 +45,10 @@ export function UserProvider({

const fetchUser = async () => {
try {
setIsLoadingUser(true);
const currentUser = await getCurrentUser();
setUpToDateUser(currentUser);
} catch (error) {
console.error("Error fetching current user:", error);
} finally {
setIsLoadingUser(false);
}
};
const updateUserAutoScroll = async (autoScroll: boolean | null) => {
Expand Down Expand Up @@ -95,7 +90,6 @@ export function UserProvider({
<UserContext.Provider
value={{
user: upToDateUser,
isLoadingUser,
refreshUser,
updateUserAutoScroll,
isAdmin: upToDateUser?.role === UserRole.ADMIN,
Expand Down

0 comments on commit 4f99412

Please sign in to comment.