Skip to content

Commit

Permalink
remove unused loading text for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed May 3, 2023
1 parent de89c6d commit 5bbc5e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 50 deletions.
21 changes: 8 additions & 13 deletions app/packages/core/src/components/SamplesContainer.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -82,22 +82,17 @@ function SamplesContainer() {
return {
children: (
<Entries.Empty
useText={
group === "tags"
? () => 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 };
}
},
[]
Expand Down
51 changes: 14 additions & 37 deletions app/packages/state/src/recoil/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
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,
VALID_LABEL_TYPES,
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,
Expand All @@ -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",
Expand Down Expand Up @@ -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] => {
Expand Down

0 comments on commit 5bbc5e6

Please sign in to comment.