waitingReason.ts 994 B

1234567891011121314151617181920212223
  1. /**
  2. * Reading the scheduler's `waiting_reason` (#3074).
  3. *
  4. * The backend writes one sentence per held queue item and encodes one bit in
  5. * its shape: a reason made only of `Busy: ...` clauses means the job starts by
  6. * itself once a printer frees up, and anything else means somebody has to do
  7. * something — load filament, switch a printer on, confirm a plate. The
  8. * scheduler uses that bit to decide whether a hold is worth a notification
  9. * (`PrintScheduler._is_busy_only`), and the UI needs the same distinction to
  10. * decide whether a held item still belongs on a forecast.
  11. *
  12. * Kept in one place on this side too, so the two halves of the contract are one
  13. * grep apart.
  14. */
  15. /** Does this reason mean "waiting its turn", rather than "waiting for you"? */
  16. export function isBusyOnlyWaitingReason(reason: string | null | undefined): boolean {
  17. if (!reason) return false;
  18. return reason
  19. .split(' | ')
  20. .map(part => part.trim())
  21. .every(part => part.startsWith('Busy:'));
  22. }