From a51126fb06e255a4a8b8d61065d27874dcd8d929 Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Wed, 27 Nov 2024 12:08:16 +0100 Subject: [PATCH] Fix history label timestamp used in restore file (#22068) GitOrigin-RevId: 24e3b005664cecc017b610812cb4c666dfb55290 --- .../history/components/change-list/label-list-item.tsx | 8 ++++---- services/web/frontend/js/features/utils/format-date.js | 9 --------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx index 26d8c63145..c1223d7ec7 100644 --- a/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx +++ b/services/web/frontend/js/features/history/components/change-list/label-list-item.tsx @@ -1,7 +1,7 @@ import { memo, useCallback } from 'react' import { UpdateRange, Version } from '../../services/types/update' import TagTooltip from './tag-tooltip' -import { formatTimeBasedOnYear, isoToUnix } from '../../../utils/format-date' +import { formatTimeBasedOnYear } from '../../../utils/format-date' import HistoryDropdown from './dropdown/history-dropdown' import HistoryVersionDetails from './history-version-details' import { LoadedLabel } from '../../services/types/label' @@ -49,9 +49,9 @@ function LabelListItem({ const { t } = useTranslation() // first label - const fromVTimestamp = isoToUnix(labels[labels.length - 1].created_at) + const fromVTimestamp = Date.parse(labels[labels.length - 1].created_at) // most recent label - const toVTimestamp = isoToUnix(labels[0].created_at) + const toVTimestamp = Date.parse(labels[0].created_at) const updateRange: UpdateRange = { fromV: version, @@ -92,7 +92,7 @@ function LabelListItem({ version={version} projectId={projectId} closeDropdownForItem={closeDropdownForItem} - endTimestamp={toVTimestamp * 1000} + endTimestamp={toVTimestamp} /> ) : null} diff --git a/services/web/frontend/js/features/utils/format-date.js b/services/web/frontend/js/features/utils/format-date.js index fbef24331e..8d748ae291 100644 --- a/services/web/frontend/js/features/utils/format-date.js +++ b/services/web/frontend/js/features/utils/format-date.js @@ -26,12 +26,3 @@ export function formatTimeBasedOnYear(date) { ? formatTime(date, 'D MMMM YYYY, h:mm a') : formatTime(date, 'D MMMM, h:mm a') } - -/** - * @param {string} isoTimestamp - * @returns {number} - */ -export function isoToUnix(isoTimestamp) { - const unixTimestamp = Date.parse(isoTimestamp) / 1000 - return unixTimestamp -}