Skip to content

Commit

Permalink
Remove mildly annoying groups fetch (onyx-dot-app#2733)
Browse files Browse the repository at this point in the history
* remove mildly annoying groups fetch

* ensure in client component
  • Loading branch information
pablonyx authored Oct 9, 2024
1 parent f83e680 commit 10f221c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions web/src/lib/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import {
ConnectorIndexingStatus,
DocumentBoostStatus,
Expand All @@ -6,14 +7,14 @@ import {
} from "@/lib/types";
import useSWR, { mutate, useSWRConfig } from "swr";
import { errorHandlingFetcher } from "./fetcher";
import { useEffect, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { DateRangePickerValue } from "@tremor/react";
import { SourceMetadata } from "./search/interfaces";
import { destructureValue } from "./llm/utils";
import { ChatSession } from "@/app/chat/interfaces";
import { UsersResponse } from "./users/interfaces";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import { Credential } from "./connectors/credentials";
import { SettingsContext } from "@/components/settings/SettingsProvider";

const CREDENTIAL_URL = "/api/manage/admin/credential";

Expand Down Expand Up @@ -220,8 +221,14 @@ export const useUserGroups = (): {
error: string;
refreshUserGroups: () => void;
} => {
const swrResponse = useSWR<UserGroup[]>(USER_GROUP_URL, errorHandlingFetcher);
const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();
const combinedSettings = useContext(SettingsContext);
const isPaidEnterpriseFeaturesEnabled =
combinedSettings && combinedSettings.enterpriseSettings !== null;

const swrResponse = useSWR<UserGroup[]>(
isPaidEnterpriseFeaturesEnabled ? USER_GROUP_URL : null,
errorHandlingFetcher
);

if (!isPaidEnterpriseFeaturesEnabled) {
return {
Expand Down

0 comments on commit 10f221c

Please sign in to comment.