Feedback sweep: spinners on every async button, toasts for action outcomes, top activity bar, loading states on every page, terminal connecting overlay, dashboard save indicator, task pane pinned above the package list with auto-scroll and completion toast
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
d08b246b5f
commit
724f30c02b
+20
-6
@@ -1,12 +1,26 @@
|
||||
export class Unauthenticated extends Error {}
|
||||
|
||||
let inflight = 0
|
||||
function track(delta: number) {
|
||||
inflight += delta
|
||||
window.dispatchEvent(new CustomEvent('hamlab:inflight', { detail: inflight }))
|
||||
}
|
||||
|
||||
async function req<T>(method: string, path: string, body?: unknown): Promise<T> {
|
||||
const r = await fetch(path, {
|
||||
method,
|
||||
credentials: 'same-origin',
|
||||
headers: body !== undefined ? { 'Content-Type': 'application/json' } : undefined,
|
||||
body: body !== undefined ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
track(1)
|
||||
let r: Response
|
||||
try {
|
||||
r = await fetch(path, {
|
||||
method,
|
||||
credentials: 'same-origin',
|
||||
headers: body !== undefined ? { 'Content-Type': 'application/json' } : undefined,
|
||||
body: body !== undefined ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
} catch (e) {
|
||||
track(-1)
|
||||
throw new Error('network error')
|
||||
}
|
||||
track(-1)
|
||||
if (r.status === 401) throw new Unauthenticated()
|
||||
if (!r.ok) {
|
||||
let msg = r.statusText
|
||||
|
||||
Reference in New Issue
Block a user