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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user