utils.tsx 624 B

123456789101112131415161718192021222324
  1. import type {Location} from 'history';
  2. import {decodeInteger} from 'sentry/utils/queryString';
  3. export const ZOOM_START = 'startDuration';
  4. export const ZOOM_END = 'endDuration';
  5. export function decodeHistogramZoom(location: Location) {
  6. let min: number | undefined = undefined;
  7. let max: number | undefined = undefined;
  8. if (ZOOM_START in location.query) {
  9. min = decodeInteger(location.query[ZOOM_START], 0);
  10. }
  11. if (ZOOM_END in location.query) {
  12. const decodedMax = decodeInteger(location.query[ZOOM_END]);
  13. if (typeof decodedMax === 'number') {
  14. max = decodedMax;
  15. }
  16. }
  17. return {min, max};
  18. }