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
+6 -15
View File
@@ -3,6 +3,7 @@ import { onMounted, ref } from "vue";
import { api } from "../api/client";
import { errorMessage } from "../api/errors";
import { formatShortDateTime } from "../notes/datetime";
import { useLoad } from "../composables/useAction";
// Admin: what has happened to accounts on this instance, newest first (#2939 §5).
// Kept for `audit_retention_days` (Settings → Security).
@@ -45,28 +46,18 @@ const REFUSALS = new Set([
const events = ref<AuditEvent[]>([]);
const more = ref(false);
const loading = ref(true);
const { loading, error, load } = useLoad(async () => {
const res = await page();
events.value = res.events;
more.value = res.more;
}, "Couldn't load activity.");
const loadingMore = ref(false);
const error = ref("");
async function page(before?: string) {
const query = before ? `?before=${encodeURIComponent(before)}` : "";
return api.get<{ events: AuditEvent[]; more: boolean }>(`/api/accounts/activity${query}`);
}
async function load() {
error.value = "";
try {
const res = await page();
events.value = res.events;
more.value = res.more;
} catch (e) {
error.value = errorMessage(e, "Couldn't load activity.");
} finally {
loading.value = false;
}
}
async function loadMore() {
const last = events.value[events.value.length - 1];
if (!last) return;