redraw updated table when using active toggle switch
This commit is contained in:
parent
e486885a03
commit
1e9b9e905d
@ -78,12 +78,20 @@ function initSubscriptionTable() {
|
||||
|
||||
$("#subTable").on("change", ".sub-toggle-active", async function () {
|
||||
|
||||
// Lock all toggles to soft-prevent spam.
|
||||
// There is a rate limit, but allowing the user to
|
||||
// reach it from this toggle would be bad.
|
||||
$(".sub-toggle-active").prop("disabled", true);
|
||||
|
||||
try {
|
||||
const active = $(this).prop("checked");
|
||||
const sub = subTable.row($(this).closest("tr")).data();
|
||||
|
||||
|
||||
// Update the table row
|
||||
sub.active = active;
|
||||
subTable.data(sub).draw();
|
||||
|
||||
// Update the database
|
||||
const subPrimaryKey = await saveSubscription(
|
||||
sub.id,
|
||||
sub.name,
|
||||
@ -101,6 +109,7 @@ $("#subTable").on("change", ".sub-toggle-active", async function () {
|
||||
);
|
||||
}
|
||||
finally {
|
||||
// Re-enable toggles after 500ms
|
||||
setTimeout(() => { $(".sub-toggle-active").prop("disabled", false); }, 500)
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user