Skip to content

Commit

Permalink
Misc: Resolve future TS version errors [no-ci] (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
fearnlj01 authored Jun 13, 2024
1 parent 85abda0 commit e71eaf6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/components/Utilities/UtilitiesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const Row = (
);
};

const isFileSortCriteriaEnum = (type: unknown): type is keyof typeof FileSortCriteriaEnum => typeof type === 'number';
const isCriteriaMapKey = (type: string): type is keyof typeof criteriaMap => type in criteriaMap;

const HeaderItem = (
props: {
Expand Down Expand Up @@ -165,20 +165,17 @@ const HeaderItem = (
}

const handleSortCriteriaChange = (headerId: string) => {
if (skipSort || !isFileSortCriteriaEnum(criteriaMap[headerId])) return;
const criteria = criteriaMap[headerId] as FileSortCriteriaEnum;
if (skipSort || !isCriteriaMapKey(headerId)) return;
const criteria = criteriaMap[headerId];
if (!criteria || !setSortCriteria) return;

setSortCriteria((tempCriteria) => {
if (tempCriteria === criteria) return tempCriteria * -1;
return criteria;
});
setSortCriteria(prevCriteria => ((prevCriteria === criteria) ? -criteria : criteria));
};

const sortIndicator = (headerId: string) => {
if (skipSort || !isFileSortCriteriaEnum(criteriaMap[headerId])) return null;
const criteria = criteriaMap[headerId] as number;
if (!criteria || !sortCriteria || Math.abs(sortCriteria) !== criteria) return null;
if (skipSort || !isCriteriaMapKey(headerId)) return null;
const criteria = criteriaMap[headerId];
if (!criteria || !sortCriteria || Math.abs(sortCriteria) !== criteria as number) return null;

return (
<Icon
Expand Down

0 comments on commit e71eaf6

Please sign in to comment.