feat:only sort on reorder and cleanup changes

This commit is contained in:
lemmy mwaura
2022-12-11 23:31:31 +03:00
parent d456dcef28
commit f94bf1f206

View File

@ -266,9 +266,12 @@ export default function Dashboard() {
* Reorder rows alphabetically or in the opprosite order
*/
const reorderRows = () => {
setSortMethod(
sortMethod == "alphabetical" ? "-alphabetical" : "alphabetical"
setSortMethod(prevSort =>
prevSort == "alphabetical"
? "-alphabetical"
: "alphabetical"
);
sortValuesHandler()
};
@ -404,9 +407,8 @@ export default function Dashboard() {
});
}
// Once "Save changed is clicked", disable that button and sort values
// Once "Save changed is clicked", disable that button
setButtonReady(false);
sortValuesHandler()
pushKeys({ obj, workspaceId: router.query.id, env });
/**
@ -449,8 +451,6 @@ export default function Dashboard() {
};
const sortValuesHandler = () => {
console.log(sortMethod)
const sortedData = data.sort((a, b) =>
sortMethod == "alphabetical"
? a.key.localeCompare(b.key)
@ -600,7 +600,7 @@ export default function Dashboard() {
</div>
<div className="ml-2 min-w-max flex flex-row items-start justify-start">
<Button
onButtonPressed={reorderRows}
onButtonPressed={() => reorderRows()}
color="mineshaft"
size="icon-md"
icon={