Wizard: Sort only selected on the frontend side

This removes sorting on the frontend side where it's already handled by the content sources API.
Since we manipulate selected packages by joining the, with `currentlyRemovedPackages` list, the sorting is added there to keep the packages from jumping around when unselected.
This commit is contained in:
regexowl 2025-03-06 16:15:32 +01:00 committed by Klara Simickova
parent ff80aea171
commit fbc0ea13e6
3 changed files with 36 additions and 33 deletions

View file

@ -649,7 +649,9 @@ const Packages = () => {
selectedPackages.push(...currentlyRemovedPackages);
}
if (toggleSourceRepos === RepoToggle.INCLUDED) {
return selectedPackages;
return selectedPackages.sort((a, b) =>
sortfn(a.name, b.name, debouncedSearchTerm)
);
} else {
return [];
}
@ -666,7 +668,7 @@ const Packages = () => {
packages,
toggleSelected,
toggleSourceRepos,
]).sort((a, b) => sortfn(a.name, b.name, debouncedSearchTerm));
]);
const transformedGroups = useMemo(() => {
let combinedGroupData: GroupWithRepositoryInfo[] = [];
@ -733,7 +735,7 @@ const Packages = () => {
groups,
toggleSelected,
toggleSourceRepos,
]).sort((a, b) => sortfn(a.name, b.name, debouncedSearchTerm));
]);
const handleSearch = async (
event: React.FormEvent<HTMLInputElement>,