Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: allow customization of default visibility of labels from dataset app config #5209

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ dist/
coverage.xml
.coverage.*
pyvenv.cfg

.env

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/packages/core/src/components/Dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useTrackEvent } from "@fiftyone/analytics";
import { subscribe } from "@fiftyone/relay";
import { isModalActive } from "@fiftyone/state";
import React, { useEffect } from "react";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import ColorModal from "./ColorModal/ColorModal";
import { activeColorEntry } from "./ColorModal/state";
import EventTracker from "./EventTracker";
import Modal from "./Modal";
import SamplesContainer from "./SamplesContainer";
import EventTracker from "./EventTracker";
import { useTrackEvent } from "@fiftyone/analytics";

const Container = styled.div`
height: 100%;
Expand Down
41 changes: 29 additions & 12 deletions app/packages/core/src/components/Grid/useRefreshers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { subscribe } from "@fiftyone/relay";
import * as fos from "@fiftyone/state";
import { LRUCache } from "lru-cache";
import { useEffect, useMemo } from "react";
import { useEffect, useMemo, useRef } from "react";
import uuid from "react-uuid";
import { useRecoilValue } from "recoil";
import { useOnSidebarSelectionChange } from "../Sidebar/useOnSidebarSelectionChange";
import { gridAt, gridOffset, gridPage } from "./recoil";

const MAX_LRU_CACHE_ITEMS = 510;
Expand Down Expand Up @@ -64,18 +65,20 @@ export default function useRefreshers() {
return uuid();
}, [layoutReset, pageReset]);

useEffect(
() =>
subscribe(({ event }, { reset }) => {
if (event === "fieldVisibility") return;
useEffect(() => {
const unsubscribe = subscribe(({ event }, { reset }) => {
if (event === "fieldVisibility") return;

// if not a modal page change, reset the grid location
reset(gridAt);
reset(gridPage);
reset(gridOffset);
}),
[]
);
// if not a modal page change, reset the grid location
reset(gridAt);
reset(gridPage);
reset(gridOffset);
});

return () => {
unsubscribe();
};
}, []);

const lookerStore = useMemo(() => {
/** LOOKER STORE REFRESHER */
Expand All @@ -91,6 +94,20 @@ export default function useRefreshers() {
});
}, [reset]);

const lookerStoreRef = useRef(lookerStore);
lookerStoreRef.current = lookerStore;

const gridLabelsToggleTracker = useOnSidebarSelectionChange({ modal: false });

/**
* Refresh all lookers when the labels toggle tracker changes
*/
useEffect(() => {
lookerStoreRef.current?.forEach((looker) => {
looker.refreshSample();
});
}, [gridLabelsToggleTracker]);

return {
lookerStore,
pageReset,
Expand Down
1 change: 1 addition & 0 deletions app/packages/core/src/components/Grid/useSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function useSelect(

const selected = useRecoilValue(fos.selectedSamples);
useEffect(() => {
console.log(">>>ben");
deferred(() => {
const fontSize = getFontSize();
const retained = new Set<string>();
Expand Down
9 changes: 8 additions & 1 deletion app/packages/core/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { HelpPanel, JSONPanel } from "@fiftyone/components";
import { OPERATOR_PROMPT_AREAS, OperatorPromptArea } from "@fiftyone/operators";
import * as fos from "@fiftyone/state";
import React, { useCallback, useMemo, useRef } from "react";
import React, { useCallback, useEffect, useMemo, useRef } from "react";
import ReactDOM from "react-dom";
import { useRecoilCallback, useRecoilValue } from "recoil";
import styled from "styled-components";
import { ModalActionsRow } from "../Actions";
import Sidebar from "../Sidebar";
import { useOnSidebarSelectionChange } from "../Sidebar/useOnSidebarSelectionChange";
import ModalNavigation from "./ModalNavigation";
import { ModalSpace } from "./ModalSpace";
import { TooltipInfo } from "./TooltipInfo";
Expand Down Expand Up @@ -178,6 +179,12 @@ const Modal = () => {

const activeLookerRef = useRef<fos.Lookers>();

const labelsToggleTracker = useOnSidebarSelectionChange({ modal: true });

useEffect(() => {
activeLookerRef.current?.refreshSample();
}, [labelsToggleTracker]);

const addTooltipEventHandler = useTooltipEventHandler();
const removeTooltipEventHanlderRef = useRef<ReturnType<
typeof addTooltipEventHandler
Expand Down
Loading