(action, busyText = ui().status.busy, options = {})
| 1702 | } |
| 1703 | |
| 1704 | async function runAction(action, busyText = ui().status.busy, options = {}) { |
| 1705 | const actionButton = options.button || state.lastActionButton; |
| 1706 | try { |
| 1707 | setActionButtonBusy(actionButton, true); |
| 1708 | setStatus(busyText); |
| 1709 | await action(); |
| 1710 | setStatus(ui().status.ready); |
| 1711 | flashButtonFeedback(actionButton, "success"); |
| 1712 | } catch (error) { |
| 1713 | setStatus(ui().status.error); |
| 1714 | console.error(error); |
| 1715 | flashButtonFeedback(actionButton, "error"); |
| 1716 | if (!error.paperflowToastShown) showFeedbackToast("error", ui().common.operationFailed, error.message || String(error)); |
| 1717 | } finally { |
| 1718 | setActionButtonBusy(actionButton, false); |
| 1719 | } |
| 1720 | } |
| 1721 | |
| 1722 | async function api(path, options = {}) { |
| 1723 | if (DEMO_MODE) return demoApi(path, options); |
no test coverage detected