diff --git a/app/packages/core/src/components/SamplesContainer.tsx b/app/packages/core/src/components/SamplesContainer.tsx index 7fff5114960..56086e78a43 100644 --- a/app/packages/core/src/components/SamplesContainer.tsx +++ b/app/packages/core/src/components/SamplesContainer.tsx @@ -1,10 +1,10 @@ +import * as fos from "@fiftyone/state"; +import { Controller } from "@react-spring/web"; import React, { useCallback } from "react"; import { useRecoilValue } from "recoil"; -import { Controller } from "@react-spring/web"; import styled from "styled-components"; -import Sidebar, { Entries } from "./Sidebar"; -import * as fos from "@fiftyone/state"; import MainSpace from "./MainSpace"; +import Sidebar, { Entries } from "./Sidebar"; const Container = styled.div` display: flex; @@ -82,22 +82,17 @@ function SamplesContainer() { return { children: ( fos.useTagText(false) - : group === "label tags" - ? () => fos.useLabelTagText(false) - : () => ({ - text: "No fields", - }) - } + useText={() => ({ + text: "No fields", + loading: false, + })} key={key} /> ), disabled: true, }; default: - throw new Error("invalid entry"); + return { children: null, disabled: false }; } }, [] diff --git a/app/packages/state/src/recoil/sidebar.ts b/app/packages/state/src/recoil/sidebar.ts index 99b835598bf..7147b669518 100644 --- a/app/packages/state/src/recoil/sidebar.ts +++ b/app/packages/state/src/recoil/sidebar.ts @@ -1,17 +1,9 @@ -import { - atomFamily, - DefaultValue, - selector, - selectorFamily, - useRecoilStateLoadable, - useRecoilValue, - useRecoilValueLoadable, -} from "recoil"; +import { setSidebarGroups, setSidebarGroupsMutation } from "@fiftyone/relay"; import { DICT_FIELD, EMBEDDED_DOCUMENT_FIELD, - LABELS_PATH, LABEL_DOC_TYPES, + LABELS_PATH, LIST_FIELD, Schema, StrictField, @@ -19,8 +11,18 @@ import { VALID_PRIMITIVE_TYPES, withPath, } from "@fiftyone/utilities"; - +import { commitMutation, VariablesOf } from "react-relay"; +import { + atomFamily, + DefaultValue, + selector, + selectorFamily, + useRecoilStateLoadable, + useRecoilValue, +} from "recoil"; +import { getCurrentEnvironment } from "../hooks/useRouter"; import * as aggregationAtoms from "./aggregations"; +import { isLargeVideo } from "./options"; import { buildSchema, field, @@ -29,14 +31,9 @@ import { filterPaths, pathIsShown, } from "./schema"; - +import { datasetName, isVideoDataset, stateSubscription } from "./selectors"; import { State } from "./types"; import * as viewAtoms from "./view"; -import { datasetName, isVideoDataset, stateSubscription } from "./selectors"; -import { isLargeVideo } from "./options"; -import { commitMutation, VariablesOf } from "react-relay"; -import { setSidebarGroups, setSidebarGroupsMutation } from "@fiftyone/relay"; -import { getCurrentEnvironment } from "../hooks/useRouter"; export enum EntryKind { EMPTY = "EMPTY", @@ -93,26 +90,6 @@ export const readableTags = selectorFamily< }, }); -export const useLabelTagText = (modal: boolean) => { - const loading = - useRecoilValueLoadable(readableTags({ modal, group: "label tags" })) - .state === "loading"; - - return { text: loading ? "Loading label tags" : "No label tags", loading }; -}; - -export const useTagText = (modal: boolean) => { - const { singular } = useRecoilValue(viewAtoms.elementNames); - const loading = - useRecoilValueLoadable(readableTags({ modal, group: "tags" })).state === - "loading"; - - return { - text: loading ? `Loading ${singular} tags` : `No ${singular} tags`, - loading, - }; -}; - export const useEntries = ( modal: boolean ): [SidebarEntry[], (entries: SidebarEntry[]) => void] => {