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:
@@ -5,7 +5,7 @@ import { errorMessage } from "../api/errors";
|
||||
import BaseButton from "./BaseButton.vue";
|
||||
import BaseInput from "./BaseInput.vue";
|
||||
import Icon from "./Icon.vue";
|
||||
import { useRowAction } from "../composables/useAction";
|
||||
import { useRowAction, useLoad } from "../composables/useAction";
|
||||
|
||||
// Admin: groups of people a note can be shared with in one go (#5177). A group is
|
||||
// the instance's; anyone can share with it, and a note shared with it reaches whoever
|
||||
@@ -23,11 +23,16 @@ interface Group {
|
||||
members: Person[];
|
||||
}
|
||||
|
||||
|
||||
const groups = ref<Group[]>([]);
|
||||
const accounts = ref<Person[]>([]);
|
||||
const loading = ref(true);
|
||||
const error = ref("");
|
||||
const { loading, error, load } = useLoad(async () => {
|
||||
const [g, a] = await Promise.all([
|
||||
api.get<{ groups: Group[] }>("/api/groups"),
|
||||
api.get<{ accounts: Person[] }>("/api/accounts"),
|
||||
]);
|
||||
groups.value = g.groups;
|
||||
accounts.value = a.accounts;
|
||||
}, "Couldn't load groups.");
|
||||
const name = ref("");
|
||||
const creating = ref(false);
|
||||
const { busy, act } = useRowAction();
|
||||
@@ -43,22 +48,6 @@ function outside(group: Group): Person[] {
|
||||
|
||||
const empty = computed(() => !loading.value && !groups.value.length);
|
||||
|
||||
async function load() {
|
||||
error.value = "";
|
||||
try {
|
||||
const [g, a] = await Promise.all([
|
||||
api.get<{ groups: Group[] }>("/api/groups"),
|
||||
api.get<{ accounts: Person[] }>("/api/accounts"),
|
||||
]);
|
||||
groups.value = g.groups;
|
||||
accounts.value = a.accounts;
|
||||
} catch (e) {
|
||||
error.value = errorMessage(e, "Couldn't load groups.");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function replace(updated: Group) {
|
||||
groups.value = groups.value.map((g) => (g.id === updated.id ? updated : g)).sort(byName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user