fix(ui): keep proposals visible during background refresh
Quality / check (pull_request) Successful in 3m9s

(cherry picked from commit 7334f659fd14f68186f009279dc6cda4c4cd56fd)
This commit is contained in:
sam committed 2026-11-27 15:59:18 +11:00
1 parent f6eff43ca4
commit 2e9d14412e
2 files changed
+124 -7

No files matched your search

+12 -7
View File
@@ -15,14 +15,19 @@ import { useLiveResource } from "@/stores/session";
import { kindLabel, proposalTone, STATES } from "./state";
const state = ref<ProposalState>("pending");
const { data, error, reload } = useRead(() => api.proposals(state.value));
const { data, error, loading, reload } = useRead(() => api.proposals(state.value));
onMounted(reload);
watch(state, () => {
data.value = undefined;
error.value = "";
void reload();
});
useLiveResource(null, () => void reload());
usePoll(reload);
// A background refresh must not supersede a slow read for the same tab.
function refresh(): void {
if (!loading.value) void reload();
}
useLiveResource(null, refresh);
usePoll(refresh);
const columns: DataTableColumn<Proposal>[] = [
{ id: "title", label: "Proposal", fixed: true, width: "auto", sort: (p) => p.title },
@@ -42,11 +47,11 @@ const columns: DataTableColumn<Proposal>[] = [
</TabsList>
</Tabs>
</PageHeader>
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
<div v-else-if="!data" role="status" aria-label="Loading proposals" class="space-y-2"><Skeleton class="h-10 w-full" /><Skeleton class="h-10 w-full" /></div>
<Empty v-else-if="!data.length"><EmptyHeader><EmptyTitle>No proposals</EmptyTitle></EmptyHeader></Empty>
<ReadError v-if="error" :class="data && 'mb-2'" :message="error" retry-label="Retry" @retry="reload" />
<div v-if="!data && !error" role="status" aria-label="Loading proposals" class="space-y-2"><Skeleton class="h-10 w-full" /><Skeleton class="h-10 w-full" /></div>
<Empty v-else-if="data && !data.length"><EmptyHeader><EmptyTitle>No proposals</EmptyTitle></EmptyHeader></Empty>
<DataTable
v-else
v-else-if="data"
:columns="columns"
:rows="data"
:row-key="(p) => p.id"