fix(badges): skip PATCH and print immediately when offline or API unreachable
When navigator.onLine is false or the account is ghost (API unreachable),
bypass the 20-second API timeout entirely and fire window.print() at once.
The existing error state ("Printed — count NOT saved") already covers this
case. Staff can correct the print count manually after connectivity returns.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -225,6 +225,17 @@ async function handle_print_badge() {
|
|||||||
};
|
};
|
||||||
if (is_first_print) data_to_update.print_first_datetime = now;
|
if (is_first_print) data_to_update.print_first_datetime = now;
|
||||||
|
|
||||||
|
// Offline or API unreachable: skip the PATCH and print immediately.
|
||||||
|
// Never block a physical print for a network issue — staff can correct the
|
||||||
|
// count manually in the Admin section after connectivity is restored.
|
||||||
|
if (!navigator.onLine || $ae_loc?.account_id === 'ghost') {
|
||||||
|
if (browser) window.print();
|
||||||
|
print_status = 'error';
|
||||||
|
await new Promise<void>((r) => setTimeout(r, 4000));
|
||||||
|
if (browser) window.location.href = `/events/${event_id}/badges`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await events_func.update_ae_obj__event_badge({
|
const result = await events_func.update_ae_obj__event_badge({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
|
|||||||
Reference in New Issue
Block a user