cameraTestMessage.ts 959 B

1234567891011121314151617181920212223
  1. import type { TFunction } from 'i18next';
  2. interface CameraTestResult {
  3. resolution?: string;
  4. coalesced?: boolean;
  5. live_view?: boolean;
  6. }
  7. /**
  8. * The toast for a successful external camera test.
  9. *
  10. * A frame from the live view or from a capture already running is real, but
  11. * it was not fetched over a connection this test opened, so the message says
  12. * where it came from rather than implying the camera was just reached.
  13. * The strings put the resolution straight after the word, so it carries its
  14. * own leading space and brackets.
  15. */
  16. export function cameraTestSuccessMessage(result: CameraTestResult, t: TFunction): string {
  17. const resolution = result.resolution ? ` (${result.resolution})` : '';
  18. if (result.live_view) return t('settings.toast.cameraConnectedLiveView', { resolution });
  19. if (result.coalesced) return t('settings.toast.cameraConnectedCoalesced', { resolution });
  20. return t('settings.toast.cameraConnected', { resolution });
  21. }