Skip to content

Commit

Permalink
Move search state to store
Browse files Browse the repository at this point in the history
  • Loading branch information
notmd committed Nov 8, 2024
1 parent 00b9964 commit ab7eedb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/entity/EntitiesTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const EntitiesTreeView = memo(function EntitiesTreeView() {
}
}, [newlySpawnedEntity, childParentMap]);

const [searchValue, setSearchValue] = useState<string | undefined>();
const searchValue = useStore((state) => state.entitySearch);
const searchMatch = useCallback((node: NodeApi<EntityTreeNode>, searchTerm: string) => {
if (!searchTerm) {
return true;
Expand All @@ -104,7 +104,7 @@ export const EntitiesTreeView = memo(function EntitiesTreeView() {
return false;
}

return match.score >= 0.5;
return match.score >= 0.3;
}, []);

if (entityTrees.length === 0) {
Expand All @@ -118,7 +118,7 @@ export const EntitiesTreeView = memo(function EntitiesTreeView() {
className="my-1 mx-2 bg-muted/50 hover:bg-accent h-10"
placeholder="Search"
value={searchValue}
onChange={(e) => setSearchValue(e.target.value)}
onChange={(e) => useStore.setState({ entitySearch: e.target.value })}
></Input>
<Filter className="size-5 absolute right-4 top-1/2 -translate-y-1/2 text-muted-foreground"></Filter>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/entity/createInspectorSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type InspectorSlice = {
component: ComponentId,
collapsed: boolean,
) => void;
entitySearch?: string;
};

export const createInspectorSlice: CreateSlice<InspectorSlice> = (set, get) => ({
Expand Down

0 comments on commit ab7eedb

Please sign in to comment.