Skip to content

Commit

Permalink
always be debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Nov 10, 2022
1 parent fdc0082 commit 29a1d77
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion app/packages/app/src/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const Network: React.FC<{
};

export const NetworkRenderer = ({ makeRoutes }) => {
const refreshRouter = useRecoilValue(fos.refresher);
const { context, environment } = fos.useRouter(makeRoutes, []);

const isModalActive = Boolean(useRecoilValue(fos.modal));
Expand Down
17 changes: 7 additions & 10 deletions app/packages/core/src/Dataset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fos from "@fiftyone/state";
import { toCamelCase } from "@fiftyone/utilities";
import { useEffect, useLayoutEffect, useState } from "react";
import { useContext, useLayoutEffect, useState } from "react";
import { graphql, usePreloadedQuery, useQueryLoader } from "react-relay";

import {
Expand Down Expand Up @@ -108,14 +108,12 @@ const DatasetQuery = graphql`
}
`;

export function usePrepareDataset(
dataset,
{ colorscale, config, state },
setReady
) {
export function usePrepareDataset(dataset, setReady) {
const update = fos.useStateUpdate();
const router = useContext(fos.RouterContext);

useLayoutEffect(() => {
const { colorscale, config, state } = router.state;
if (dataset) {
update(() => {
return {
Expand All @@ -129,16 +127,15 @@ export function usePrepareDataset(
});
setReady(true);
}
}, [dataset, colorscale, config, state]);
}, [dataset, router]);
}
export function usePreLoadedDataset(
queryRef,
{ colorscale, config, state } = {}
queryRef
): [DatasetQuery$data["dataset"], boolean] {
const [ready, setReady] = useState(false);

const { dataset } = usePreloadedQuery<DatasetQuery>(DatasetQuery, queryRef);
usePrepareDataset(dataset, { colorscale, config, state }, setReady);
usePrepareDataset(dataset, setReady);
return [dataset, ready];
}
export function useDatasetLoader() {
Expand Down
2 changes: 1 addition & 1 deletion app/packages/core/src/Root/Datasets/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DatasetQuery } from "../../__generated__/DatasetQuery.graphql";

export const Dataset: Route<DatasetQuery> = ({ prepared }) => {
const router = useContext(RouterContext);
const [dataset, ready] = usePreLoadedDataset(prepared, router?.state);
const [dataset, ready] = usePreLoadedDataset(prepared);
const name = useRecoilValue(fos.datasetName);
if (!ready) return null;
if (dataset === null) {
Expand Down
8 changes: 5 additions & 3 deletions app/packages/state/src/recoil/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ export const resolveGroups = (
}, {})
: {};
if (!groups) {
groups = dataset.frameFields.length
? DEFAULT_VIDEO_GROUPS
: DEFAULT_IMAGE_GROUPS;
groups = JSON.parse(
JSON.stringify(
dataset.frameFields.length ? DEFAULT_VIDEO_GROUPS : DEFAULT_IMAGE_GROUPS
)
);
}

groups = groups.map((group) => {
Expand Down

0 comments on commit 29a1d77

Please sign in to comment.