Skip to content

Commit

Permalink
lint, only update router state if present (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane authored and Jacob Marks committed Dec 6, 2022
1 parent 0b03275 commit c5830bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
14 changes: 4 additions & 10 deletions app/packages/dataset/src/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,19 @@ import {
} from "@fiftyone/core";
import { usePlugins } from "@fiftyone/plugins";
import * as fos from "@fiftyone/state";
import { getEventSource, toCamelCase } from "@fiftyone/utilities";
import { getEnvironment, RelayEnvironmentKey, State } from "@fiftyone/state";
import React, { useEffect, useState, Suspense } from "react";
import { PreloadedQuery, useQueryLoader, usePreloadedQuery } from "react-relay";
import { getEnvironment, RelayEnvironmentKey } from "@fiftyone/state";
import React, { useState, Suspense } from "react";
import { PreloadedQuery, useQueryLoader } from "react-relay";
import { RecoilRoot, useRecoilValue, useSetRecoilState } from "recoil";
import { RecoilRelayEnvironmentProvider } from "recoil-relay";
import styled from "styled-components";

import { DatasetQuery, DatasetQuery$data } from "@fiftyone/core";
import { DatasetQuery } from "@fiftyone/core";

// built-in plugins
import "@fiftyone/looker-3d";
import "@fiftyone/map";

enum Events {
STATE_UPDATE = "state_update",
}

const Container = styled.div`
width: 100%;
height: 100%;
Expand Down Expand Up @@ -96,7 +91,6 @@ export const DatasetRenderer: React.FC<DatasetProps> = ({
setCompactLayout(compactLayout);
}, [compactLayout]);
React.useEffect(() => {
console.log(dataset);
loadQuery({ name: dataset });
}, [dataset]);
React.useLayoutEffect(() => {
Expand Down
17 changes: 10 additions & 7 deletions app/packages/state/src/hooks/useSetView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ const useSetView = (
},
onError,
onCompleted: ({ setView: { dataset, view: value } }) => {
router.history.location.state.state = {
...router.history.location.state,
view: value,
viewCls: dataset.viewCls,
selected: [],
selectedLabels: [],
};
if (router.history.location.state) {
router.history.location.state.state = {
...router.history.location.state,
view: value,
viewCls: dataset.viewCls,
selected: [],
selectedLabels: [],
};
}

updateState({
dataset: transformDataset(dataset),
state: {
Expand Down

0 comments on commit c5830bc

Please sign in to comment.