Skip to content

Commit

Permalink
removed commit sort, added LinesSort to dependancy array
Browse files Browse the repository at this point in the history
  • Loading branch information
KartikChawla09 authored and e-for-eshaan committed Jun 21, 2024
1 parent 851fd5c commit 4c29a8a
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions web-server/src/hooks/useTableSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,6 @@ export const useTableSort = <T = Record<string, any>>(
return result;
}, [conf.order, list, simpleSort]);

const handleCommitSort = useCallback(() => {
const result = [...list] as any[];
if (!result.some((pr) => pr?.commits)) return simpleSort();
if (conf.order === 'asc') {
result.sort((a, b) => {
return Number(a.commits) - Number(b.commits);
});
} else {
result.sort((b, a) => {
return Number(a.commits) - Number(b.commits);
});
}
return result;
}, [conf.order, list, simpleSort]);

const handleLinesSort = useCallback(() => {
const result = [...list] as any[];
if (!result.some((pr) => pr?.additions)) return simpleSort();
Expand All @@ -137,14 +122,14 @@ export const useTableSort = <T = Record<string, any>>(
if (conf.field === 'author') return handleAuthorUsernameSort();
if (conf.field === 'reviewers') return handleReviewerSort();
if (conf.field === 'first_response_time') return handleResponseTime();
if (conf.field === 'commits') return handleCommitSort();
if (conf.field === 'additions') return handleLinesSort();
return simpleSort();
}, [
conf.field,
handleAuthorUsernameSort,
handleResponseTime,
handleReviewerSort,
handleLinesSort,
simpleSort
]);

Expand Down

0 comments on commit 4c29a8a

Please sign in to comment.