diff --git a/client/src/CommandBar/steps/AddToStudio.tsx b/client/src/CommandBar/steps/AddToStudio.tsx index 72a34d0eaa..d0ce9ed69b 100644 --- a/client/src/CommandBar/steps/AddToStudio.tsx +++ b/client/src/CommandBar/steps/AddToStudio.tsx @@ -156,7 +156,7 @@ const AddToStudio = (props: Props) => { const newSectionsToShow: CommandBarSectionType[] = []; initialSections.forEach((s) => { const items = (s.items as CommandBarItemGeneralType[]).filter((item) => { - return item.label.toLowerCase().includes(inputValue.toLowerCase()); + return item.label?.toLowerCase().includes(inputValue?.toLowerCase()); }); if (items.length) { diff --git a/client/src/CommandBar/steps/Documentation/index.tsx b/client/src/CommandBar/steps/Documentation/index.tsx index 2544e793af..2c69bc823d 100644 --- a/client/src/CommandBar/steps/Documentation/index.tsx +++ b/client/src/CommandBar/steps/Documentation/index.tsx @@ -177,10 +177,11 @@ const Documentation = ({}: Props) => { } const newSections: CommandBarSectionType[] = []; sections.forEach((s) => { - const newItems = s.items.filter((i) => - ('label' in i ? i.label : i.componentProps.doc.name) - .toLowerCase() - .includes(inputValue.toLowerCase()), + const newItems = s.items.filter( + (i) => + ('label' in i ? i.label : i.componentProps.doc.name) + ?.toLowerCase() + .includes(inputValue?.toLowerCase()), ); if (newItems.length) { newSections.push({ ...s, items: newItems }); diff --git a/client/src/CommandBar/steps/Initial.tsx b/client/src/CommandBar/steps/Initial.tsx index a560ce18cb..53aa450b21 100644 --- a/client/src/CommandBar/steps/Initial.tsx +++ b/client/src/CommandBar/steps/Initial.tsx @@ -434,8 +434,8 @@ const InitialCommandBar = ({ shouldShowTutorial }: Props) => { } const newSections: CommandBarSectionType[] = []; initialSections.forEach((s) => { - const newItems = (s.items as CommandBarItemGeneralType[]).filter((i) => - i.label.toLowerCase().includes(inputValue.toLowerCase()), + const newItems = (s.items as CommandBarItemGeneralType[]).filter( + (i) => i.label?.toLowerCase().includes(inputValue?.toLowerCase()), ); if (newItems.length) { newSections.push({ diff --git a/client/src/CommandBar/steps/LocalRepos.tsx b/client/src/CommandBar/steps/LocalRepos.tsx index b768df533a..53152d1778 100644 --- a/client/src/CommandBar/steps/LocalRepos.tsx +++ b/client/src/CommandBar/steps/LocalRepos.tsx @@ -140,10 +140,11 @@ const LocalRepos = ({}: Props) => { } const newSections: CommandBarSectionType[] = []; sections.forEach((s) => { - const newItems = s.items.filter((i) => - ('label' in i ? i.label : i.componentProps.repo.shortName) - .toLowerCase() - .includes(inputValue.toLowerCase()), + const newItems = s.items.filter( + (i) => + ('label' in i ? i.label : i.componentProps.repo.shortName) + ?.toLowerCase() + .includes(inputValue?.toLowerCase()), ); if (newItems.length) { newSections.push({ ...s, items: newItems }); diff --git a/client/src/CommandBar/steps/ManageRepos/index.tsx b/client/src/CommandBar/steps/ManageRepos/index.tsx index 0dd2156843..7bcb3ac563 100644 --- a/client/src/CommandBar/steps/ManageRepos/index.tsx +++ b/client/src/CommandBar/steps/ManageRepos/index.tsx @@ -172,9 +172,9 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => { ) => { return 'componentProps' in item ? item.componentProps.repo.shortName - .toLowerCase() - .includes(inputValue.toLowerCase()) - : item.label.toLowerCase().includes(inputValue.toLowerCase()); + ?.toLowerCase() + .includes(inputValue?.toLowerCase()) + : item.label?.toLowerCase().includes(inputValue?.toLowerCase()); }; sections.forEach((s) => { diff --git a/client/src/CommandBar/steps/PrivateRepos/index.tsx b/client/src/CommandBar/steps/PrivateRepos/index.tsx index e7b1861e8f..42367aa428 100644 --- a/client/src/CommandBar/steps/PrivateRepos/index.tsx +++ b/client/src/CommandBar/steps/PrivateRepos/index.tsx @@ -91,8 +91,8 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => { sections.forEach((s) => { const items = (s.items as CommandBarItemCustomType[]).filter((item) => { return item.componentProps.repo.shortName - .toLowerCase() - .includes(inputValue.toLowerCase()); + ?.toLowerCase() + .includes(inputValue?.toLowerCase()); }); if (items.length) { diff --git a/client/src/Project/CurrentTabContent/ChatTab/Input/index.tsx b/client/src/Project/CurrentTabContent/ChatTab/Input/index.tsx index fb880a4400..3ab5f72586 100644 --- a/client/src/Project/CurrentTabContent/ChatTab/Input/index.tsx +++ b/client/src/Project/CurrentTabContent/ChatTab/Input/index.tsx @@ -178,7 +178,7 @@ const ConversationInput = ({ .filter( (t): t is FileTabType => t.type === TabTypesEnum.FILE && - (!search || t.path.toLowerCase().includes(search.toLowerCase())), + (!search || t.path?.toLowerCase().includes(search?.toLowerCase())), ) .map((t) => ({ path: t.path, repo: t.repoRef })); filesResults.push( diff --git a/client/src/Project/CurrentTabContent/StudioTab/Conversation/Input/TemplatesDropdown.tsx b/client/src/Project/CurrentTabContent/StudioTab/Conversation/Input/TemplatesDropdown.tsx index 74bd096b70..2d4504781a 100644 --- a/client/src/Project/CurrentTabContent/StudioTab/Conversation/Input/TemplatesDropdown.tsx +++ b/client/src/Project/CurrentTabContent/StudioTab/Conversation/Input/TemplatesDropdown.tsx @@ -39,8 +39,8 @@ const TemplatesDropdown = ({ templates, onTemplateSelected }: Props) => { setTemplatesToShow(templates); } else { setTemplatesToShow( - templates.filter((t) => - t.name.toLowerCase().includes(inputValue.toLowerCase()), + templates.filter( + (t) => t.name?.toLowerCase().includes(inputValue?.toLowerCase()), ), ); } diff --git a/client/src/Project/LeftSidebar/NavPanel/Repo/RepoDropdown.tsx b/client/src/Project/LeftSidebar/NavPanel/Repo/RepoDropdown.tsx index 15f90cf23e..8400a3ee02 100644 --- a/client/src/Project/LeftSidebar/NavPanel/Repo/RepoDropdown.tsx +++ b/client/src/Project/LeftSidebar/NavPanel/Repo/RepoDropdown.tsx @@ -113,11 +113,12 @@ const RepoDropdown = ({ if (!search) { return indexedBranches; } - return indexedBranches.filter((b) => - b - .replace(/^origin\//, '') - .toLowerCase() - .includes(search.toLowerCase()), + return indexedBranches.filter( + (b) => + b + .replace(/^origin\//, '') + ?.toLowerCase() + .includes(search?.toLowerCase()), ); }, [indexedBranches, search]); @@ -125,11 +126,12 @@ const RepoDropdown = ({ if (!search) { return branchesToSync; } - return branchesToSync.filter((b) => - b - .replace(/^origin\//, '') - .toLowerCase() - .includes(search.toLowerCase()), + return branchesToSync.filter( + (b) => + b + .replace(/^origin\//, '') + ?.toLowerCase() + .includes(search?.toLowerCase()), ); }, [branchesToSync, search]); @@ -137,11 +139,12 @@ const RepoDropdown = ({ if (!search) { return notSyncedBranches; } - return notSyncedBranches.filter((b) => - b - .replace(/^origin\//, '') - .toLowerCase() - .includes(search.toLowerCase()), + return notSyncedBranches.filter( + (b) => + b + .replace(/^origin\//, '') + ?.toLowerCase() + .includes(search?.toLowerCase()), ); }, [notSyncedBranches, search]); diff --git a/client/src/Project/LeftSidebar/NavPanel/Repo/index.tsx b/client/src/Project/LeftSidebar/NavPanel/Repo/index.tsx index de8272d877..1482f04442 100644 --- a/client/src/Project/LeftSidebar/NavPanel/Repo/index.tsx +++ b/client/src/Project/LeftSidebar/NavPanel/Repo/index.tsx @@ -72,7 +72,7 @@ const RepoNav = ({ } return resp?.entries.sort((a, b) => { if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) { - return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; + return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1; } else { return a.entry_data === 'Directory' ? -1 : 1; } diff --git a/client/src/Project/LeftSidebar/RegexSearchPanel/Results/FileResult.tsx b/client/src/Project/LeftSidebar/RegexSearchPanel/Results/FileResult.tsx index 17725e46b7..75c0166215 100644 --- a/client/src/Project/LeftSidebar/RegexSearchPanel/Results/FileResult.tsx +++ b/client/src/Project/LeftSidebar/RegexSearchPanel/Results/FileResult.tsx @@ -41,7 +41,7 @@ const FileResult = ({ } return resp?.entries.sort((a, b) => { if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) { - return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; + return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1; } else { return a.entry_data === 'Directory' ? -1 : 1; } diff --git a/client/src/Project/LeftSidebar/RegexSearchPanel/Results/RepoResult.tsx b/client/src/Project/LeftSidebar/RegexSearchPanel/Results/RepoResult.tsx index f25074b148..0db3d17f9e 100644 --- a/client/src/Project/LeftSidebar/RegexSearchPanel/Results/RepoResult.tsx +++ b/client/src/Project/LeftSidebar/RegexSearchPanel/Results/RepoResult.tsx @@ -25,7 +25,7 @@ const RepoResult = ({ repoRef, isExpandable, index }: Props) => { } return resp?.entries.sort((a, b) => { if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) { - return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; + return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1; } else { return a.entry_data === 'Directory' ? -1 : 1; } diff --git a/client/src/components/MarkdownWithCode/FolderChip.tsx b/client/src/components/MarkdownWithCode/FolderChip.tsx index 1251fc98f1..51d9a7514c 100644 --- a/client/src/components/MarkdownWithCode/FolderChip.tsx +++ b/client/src/components/MarkdownWithCode/FolderChip.tsx @@ -22,7 +22,7 @@ const FolderChip = ({ onClick, path, repoRef }: Props) => { } return resp?.entries.sort((a, b) => { if ((a.entry_data === 'Directory') === (b.entry_data === 'Directory')) { - return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; + return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1; } else { return a.entry_data === 'Directory' ? -1 : 1; } diff --git a/client/src/hooks/useCodeSearch.ts b/client/src/hooks/useCodeSearch.ts index a7631d2e6f..589b36a69b 100644 --- a/client/src/hooks/useCodeSearch.ts +++ b/client/src/hooks/useCodeSearch.ts @@ -61,7 +61,7 @@ export const useCodeSearch = ({ } const lines = code.split('\n'); const results = lines.reduce(function (prev: number[], cur, i) { - if (cur.toLowerCase().includes(deferredSearchTerm.toLowerCase())) { + if (cur?.toLowerCase().includes(deferredSearchTerm?.toLowerCase())) { prev.push(i); } return prev; diff --git a/client/src/utils/index.ts b/client/src/utils/index.ts index 7bcbb09080..e5214f8452 100644 --- a/client/src/utils/index.ts +++ b/client/src/utils/index.ts @@ -79,7 +79,7 @@ export const getFileExtensionForLang = (lang: string, lowercased?: boolean) => { // @ts-ignore let ext = langs[lang]?.[0]; if (lowercased) { - const key = Object.keys(langs).find((key) => key.toLowerCase() === lang); + const key = Object.keys(langs).find((key) => key?.toLowerCase() === lang); if (key) { // @ts-ignore ext = langs[key]?.[0]; @@ -97,7 +97,7 @@ export const getPrettyLangName = (lang: string) => { case 'tsx': return 'TypeScript'; default: - return Object.keys(langs).find((key) => key.toLowerCase() === lang); + return Object.keys(langs).find((key) => key?.toLowerCase() === lang); } }; diff --git a/client/src/utils/keyboardUtils.ts b/client/src/utils/keyboardUtils.ts index b5a7ca60d8..eb521ca194 100644 --- a/client/src/utils/keyboardUtils.ts +++ b/client/src/utils/keyboardUtils.ts @@ -21,7 +21,7 @@ export const checkEventKeys = (e: KeyboardEvent, shortcut?: string[]) => { if (!shortcut) { return false; } - const keys = shortcut.map((k) => k.toLowerCase()); + const keys = shortcut.map((k) => k?.toLowerCase()); if ( (keys.includes('cmd') && !(e.metaKey || e.ctrlKey)) || (!keys.includes('cmd') && (e.metaKey || e.ctrlKey)) @@ -53,9 +53,9 @@ export const checkEventKeys = (e: KeyboardEvent, shortcut?: string[]) => { if ( (e.altKey && keys.includes( - e.code.replace('Key', '').replace('Digit', '').toLowerCase(), + e.code.replace('Key', '').replace('Digit', '')?.toLowerCase(), )) || - (e.shiftKey && keys.includes(e.code.replace('Digit', '').toLowerCase())) + (e.shiftKey && keys.includes(e.code.replace('Digit', '')?.toLowerCase())) ) { return true; } diff --git a/client/src/utils/mappers.ts b/client/src/utils/mappers.ts index b4171b5d63..bbb06e2232 100644 --- a/client/src/utils/mappers.ts +++ b/client/src/utils/mappers.ts @@ -44,7 +44,7 @@ export const mapReposBySections = (githubRepos: RepoType[]) => { ? 1 : b === 'Local' ? -1 - : a.toLowerCase() < b.toLowerCase() + : a?.toLowerCase() < b?.toLowerCase() ? -1 : 1, ) @@ -52,11 +52,11 @@ export const mapReposBySections = (githubRepos: RepoType[]) => { result.push({ org: k, items: byOrg[k].sort((a, b) => - a.folderName.toLowerCase() < b.folderName.toLowerCase() + a.folderName?.toLowerCase() < b.folderName?.toLowerCase() ? -1 - : a.folderName.toLowerCase() > b.folderName.toLowerCase() + : a.folderName?.toLowerCase() > b.folderName?.toLowerCase() ? 1 - : a.shortName.toLowerCase() < b.shortName.toLowerCase() + : a.shortName?.toLowerCase() < b.shortName?.toLowerCase() ? -1 : 1, ),