Something went wrong. Try again.
Synapse is a study workspace. Organize courses read and annotate the material, train with generated exercises and watch your progress forked from denishovart.com/synapse
Something went wrong. Try again.
12345678910111213141516171819202122232425262728// Shared outcome handling for inline save statuses: the caller shows the// returned string next to the control, and screen readers hear it too.import type { ResultAsync } from 'neverthrow';import { announce } from '@design-system';import { m } from '@web/paraglide/messages';import type { ApiError } from './api';
// The shared failure path: error line + assertive announcement.export function errorStatus(e: ApiError): string { const message = m.common_error({ message: e.message }); announce(message, 'assertive'); return message;}
// Awaits a save, applies the value, announces the outcome and returns the// status line to display.export async function saveStatus<T>( result: ResultAsync<T, ApiError>, okMessage: string, apply?: (value: T) => void,): Promise<string> { return result.match((value) => { apply?.(value); announce(okMessage); return okMessage; }, errorStatus);}