Skip to content

Commit 370b7d9

Browse files
authored
refactor(app): Update zipfile timestamp to reflect robot-server filenames (#20070)
1 parent 4887a71 commit 370b7d9

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

app/src/organisms/Desktop/Devices/HistoricalProtocolRunDrawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ function ImagesFileDataRow({
390390
robotType: robotType,
391391
})
392392
const { data: imagesZipFile, isLoading } = useAllRunImagesRaw(run.id)
393-
const runTimestamp = format(new Date(run.createdAt), 'M/d/yy_HH:mm:ss')
393+
const formattedRunTs = format(new Date(run.createdAt), 'yyyyMMdd-HHmmss')
394394
const buildImagesZipName = (): string =>
395-
`${robotName}_${protocolName}_${runTimestamp}_${t('images')}.zip`
395+
`${robotName}_${protocolName}_${formattedRunTs}_${t('images')}.zip`
396396

397397
return (
398398
<Flex
@@ -415,7 +415,7 @@ function ImagesFileDataRow({
415415
</LegacyStyledText>
416416
</Flex>
417417
<Box width="33%">
418-
<LegacyStyledText as="p">{runTimestamp}</LegacyStyledText>
418+
<LegacyStyledText as="p">{formattedRunTs}</LegacyStyledText>
419419
</Box>
420420
<Box width="34%">
421421
<Link

app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunCamera/ImageGalleryContainer/GalleryContainerOverflowMenu.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ export function GalleryContainerOverflowMenu({
5050
source: SOURCE_RUN_RECORD,
5151
robotType,
5252
})
53-
const formattedRunTs = format(new Date(runTimestamp), 'M/d/yy_HH:mm:ss')
53+
const formattedRunTs = (() => {
54+
try {
55+
if (runTimestamp == null) return ''
56+
return format(new Date(runTimestamp), 'yyyyMMdd-HHmmss')
57+
} catch (error) {
58+
console.warn('Invalid timestamp:', runTimestamp)
59+
return ''
60+
}
61+
})()
5462
const buildImagesZipName = (): string =>
5563
`${robotName}_${protocolName}_${formattedRunTs}_${t('images')}.zip`
5664

app/src/resources/dataFiles/useImageInfo.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,26 @@ export function useImageInfo(runId: string): UseImagesInfoResult {
4949
)
5050
const items = useMemo(() => {
5151
if (data == null) return []
52-
return data.data.map(img => ({
53-
imageId: img.id,
54-
filename: img.filename,
55-
stepCommandId: img.commandId ?? '',
56-
previousStepCommandId: img.prevCommandId ?? '',
57-
timestamp: format(new Date(String(img.createdAt)), 'M/d/yy HH:mm:ss'),
58-
}))
52+
53+
return data.data.map(img => {
54+
const timestamp = (() => {
55+
try {
56+
if (img?.createdAt == null) return ''
57+
return format(new Date(String(img.createdAt)), 'M/d/yy HH:mm:ss')
58+
} catch (error) {
59+
console.warn('Invalid timestamp:', img?.createdAt)
60+
return ''
61+
}
62+
})()
63+
64+
return {
65+
imageId: img.id,
66+
filename: img.filename,
67+
stepCommandId: img.commandId ?? '',
68+
previousStepCommandId: img.prevCommandId ?? '',
69+
timestamp,
70+
}
71+
})
5972
}, [data])
6073
return { items, protocolAnalysis, isLoadingImages, allRunDefs }
6174
}

0 commit comments

Comments
 (0)