m4: per-view error states (board / search / graph / reminders)
Each data view now catches a failed load and shows an explicit error message with a Retry button, instead of falling through to a misleading empty state. Pairs with the global error toast: the toast says something failed, the view says which and offers a retry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -26,6 +26,7 @@ const notes = useNotesStore();
|
||||
const allNodes = ref<GNode[]>([]);
|
||||
const edges = ref<GEdge[]>([]);
|
||||
const loading = ref(true);
|
||||
const error = ref("");
|
||||
const editing = ref<Note | null>(null);
|
||||
const showAll = ref(false);
|
||||
|
||||
@@ -73,6 +74,7 @@ function fill(color: string): string {
|
||||
|
||||
async function loadGraph() {
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const res = await api.get<{ nodes: { id: string; title: string; color: string }[]; edges: GEdge[] }>(
|
||||
"/api/graph",
|
||||
@@ -93,6 +95,10 @@ async function loadGraph() {
|
||||
};
|
||||
});
|
||||
edges.value = res.edges;
|
||||
} catch (e) {
|
||||
error.value = (e as { error?: string }).error ?? "Couldn't load the graph.";
|
||||
allNodes.value = [];
|
||||
edges.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -289,6 +295,18 @@ onBeforeUnmount(() => {
|
||||
|
||||
<div v-if="loading" class="py-24 text-center text-sm text-neutral-400">Loading graph…</div>
|
||||
|
||||
<div v-else-if="error" class="py-24 text-center">
|
||||
<h2 class="text-lg font-semibold text-neutral-700 dark:text-neutral-200">Couldn't load the graph</h2>
|
||||
<p class="mt-1 text-sm text-neutral-400">{{ error }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 rounded-md border border-neutral-300 px-3 py-1.5 text-sm hover:bg-neutral-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand dark:border-neutral-700 dark:hover:bg-neutral-800"
|
||||
@click="loadGraph"
|
||||
>
|
||||
Retry
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="allNodes.length === 0" class="py-24 text-center">
|
||||
<h2 class="text-lg font-semibold text-neutral-700 dark:text-neutral-200">No notes yet</h2>
|
||||
<p class="mt-1 text-sm text-neutral-400">
|
||||
|
||||
Reference in New Issue
Block a user