Skip to content

Commit 003ce73

Browse files
authored
fix: search results for sandbox (#8648)
1 parent 2296388 commit 003ce73

File tree

1 file changed

+8
-7
lines changed
  • packages/app/src/app/pages/Dashboard/Content/routes/Search

1 file changed

+8
-7
lines changed

packages/app/src/app/pages/Dashboard/Content/routes/Search/searchItems.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ const useSearchedSandboxes = (query: string) => {
4848
};
4949

5050
const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
51-
const sandboxes = dashboard.sandboxes.SEARCH;
52-
if (sandboxes == null) {
53-
return null;
54-
}
51+
const sandboxes = dashboard.sandboxes.SEARCH || [];
52+
5553
const folders: Collection[] = (dashboard.allCollections || [])
5654
.map(collection => ({
5755
...collection,
@@ -60,7 +58,7 @@ const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
6058
.filter(f => f.title);
6159

6260
const teamRepos = dashboard.repositoriesByTeamId[activeTeam] ?? [];
63-
const repositories = teamRepos.map((repo: Repository) => {
61+
const repositories = (teamRepos || []).map((repo: Repository) => {
6462
return {
6563
title: repo.repository.name,
6664
/**
@@ -72,7 +70,7 @@ const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
7270
};
7371
});
7472

75-
return new Fuse([...sandboxes, ...folders, ...(repositories || [])], {
73+
return new Fuse([...sandboxes, ...folders, ...repositories], {
7674
threshold: 0.1,
7775
distance: 1000,
7876
keys: [
@@ -122,7 +120,10 @@ export const useGetItems = ({
122120
const sandbox = item as SandboxFragmentDashboardFragment;
123121

124122
// Remove draft sandboxes from other authors
125-
return sandbox.draft && sandbox.author.username === username;
123+
return (
124+
!sandbox.draft ||
125+
(sandbox.draft && sandbox.author.username === username)
126+
);
126127
}
127128
);
128129

0 commit comments

Comments
 (0)