DRY pass #2, batch 5, F16: the admin lists load through useLoad (#5372)

Accounts, groups, invites and activity each wrote the same first load:
clear the error, try, put the server's reason or a fallback in error,
and stop loading. useLoad (composables/useAction.ts) is that, and its
load() is also the retry.

Kept: ShareDialog and Settings. Their load sets loading back to true on a
reload, which the lists never did, so moving them would change what a
retry shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 14:46:14 -04:00
co-authored by Claude Opus 5.5
parent 52d53fb78a
commit 6e4c4930cb
5 changed files with 43 additions and 64 deletions
+4 -14
View File
@@ -6,7 +6,7 @@ import { appLink } from "../router/links";
import BaseButton from "./BaseButton.vue";
import BaseInput from "./BaseInput.vue";
import OneTimeLink from "./OneTimeLink.vue";
import { toastOnFailure } from "../composables/useAction";
import { toastOnFailure, useLoad } from "../composables/useAction";
// Admin: invite one person to register while registration stays closed (#5172).
// The server keeps only a hash of each invite's token, so the link is shown once,
@@ -30,25 +30,15 @@ const LIFETIMES = [
];
const invites = ref<Invite[]>([]);
const loading = ref(true);
const error = ref("");
const { loading, error, load } = useLoad(async () => {
invites.value = (await api.get<{ invites: Invite[] }>("/api/invites")).invites;
}, "Couldn't load invites.");
const email = ref("");
const days = ref(7);
const creating = ref(false);
// The link for the invite just made. Never retrievable again once dismissed.
const freshLink = ref("");
async function load() {
error.value = "";
try {
invites.value = (await api.get<{ invites: Invite[] }>("/api/invites")).invites;
} catch (e) {
error.value = errorMessage(e, "Couldn't load invites.");
} finally {
loading.value = false;
}
}
async function create() {
creating.value = true;
error.value = "";