overleaf/services/web/frontend/js/features/history/utils/range.ts
Miguel Serrano 92ade70601 Merge pull request #12933 from overleaf/ii-history-react-select-latest-version-when-all-labels-are-removed
[web] Fix history entries and labels selection issues

GitOrigin-RevId: 73b14ba15ab4f0d9ff5946b1159ae7d5912582dd
2023-05-09 08:04:00 +00:00

26 lines
592 B
TypeScript

import { UpdateRange } from '../services/types/update'
export const computeUpdateRange = (
updateRange: UpdateRange,
fromV: number,
toV: number,
updateMetaEndTimestamp: number
) => {
const fromVersion = Math.min(fromV, updateRange.fromV)
const toVersion = Math.max(toV, updateRange.toV)
const fromVTimestamp = Math.min(
updateMetaEndTimestamp,
updateRange.fromVTimestamp
)
const toVTimestamp = Math.max(
updateMetaEndTimestamp,
updateRange.toVTimestamp
)
return {
fromV: fromVersion,
toV: toVersion,
fromVTimestamp,
toVTimestamp,
}
}