code refactor

This commit is contained in:
MaysWind
2025-02-04 14:08:38 +08:00
parent 3c363788d8
commit 00d6f5d473
3 changed files with 110 additions and 100 deletions
+26 -26
View File
@@ -363,32 +363,6 @@ function setSortable(): void {
displayOrderModified.value = false;
}
function onSort(event: { el: { id: string }; from: number; to: number }): void {
if (!event || !event.el || !event.el.id) {
showToast('Unable to move account');
return;
}
const id = parseAccountIdFromDomId(event.el.id);
if (!id) {
showToast('Unable to move account');
return;
}
accountsStore.changeAccountDisplayOrder({
accountId: id,
from: event.from - 1, // first item in the list is title, so the index need minus one
to: event.to - 1,
updateListOrder: true,
updateGlobalListOrder: true
}).then(() => {
displayOrderModified.value = true;
}).catch(error => {
showToast(error.message || error);
});
}
function saveSortResult(): void {
if (!displayOrderModified.value) {
showHidden.value = false;
@@ -416,6 +390,32 @@ function saveSortResult(): void {
});
}
function onSort(event: { el: { id: string }; from: number; to: number }): void {
if (!event || !event.el || !event.el.id) {
showToast('Unable to move account');
return;
}
const id = parseAccountIdFromDomId(event.el.id);
if (!id) {
showToast('Unable to move account');
return;
}
accountsStore.changeAccountDisplayOrder({
accountId: id,
from: event.from - 1, // first item in the list is title, so the index need minus one
to: event.to - 1,
updateListOrder: true,
updateGlobalListOrder: true
}).then(() => {
displayOrderModified.value = true;
}).catch(error => {
showToast(error.message || error);
});
}
function onPageAfterIn(): void {
if (accountsStore.accountListStateInvalid && !loading.value) {
reload(null);