diff --git a/interface/src/app/status/Version.tsx b/interface/src/app/status/Version.tsx index 0d27ec461..17a452f4a 100644 --- a/interface/src/app/status/Version.tsx +++ b/interface/src/app/status/Version.tsx @@ -60,6 +60,13 @@ const DEV_RELNOTES_URL = 'https://github.com/emsesp/EMS-ESP32/blob/dev/CHANGELOG_LATEST.md'; // Types for better type safety +interface PartitionData { + partition: string; + version: string; + install_date?: string; + size: number; +} + interface VersionData { emsesp_version: string; arduino_version: string; @@ -67,6 +74,9 @@ interface VersionData { flash_chip_size: number; psram: boolean; build_flags?: string; + partition: string; + partitions: PartitionData[]; + developer_mode: boolean; } interface UpgradeCheckData { @@ -294,7 +304,7 @@ const InstallDialog = memo( return ( - {`${LL.UPDATE()} ${fetchDevVersion ? LL.DEVELOPMENT() : LL.STABLE()} Firmware`} + {`${LL.INSTALL()} ${fetchDevVersion ? LL.DEVELOPMENT() : LL.STABLE()} Firmware`} @@ -357,7 +367,9 @@ const InstallPartitionDialog = memo( }) => { return ( - Rollback Firmware + + {LL.INSTALL()} {LL.STORED_VERSIONS()} + {LL.INSTALL_VERSION(LL.INSTALL(), version)} @@ -457,9 +469,11 @@ const Version = () => { // Memoized values const platform = useMemo(() => (data ? getPlatform(data) : ''), [data]); - const isDev = useMemo( - () => data?.emsesp_version.includes('dev') ?? false, - [data?.emsesp_version] + + // Memoize filtered partitions to avoid recomputing on every render + const otherPartitions = useMemo( + () => data?.partitions.filter((p) => p.partition !== data.partition) ?? [], + [data] ); const setPartitionVersionInfo = useCallback( @@ -496,7 +510,7 @@ const Version = () => { }); await doRestart(); }, - [sendUploadURL] + [sendUploadURL, doRestart] ); const installPartitionFirmware = useCallback( @@ -702,7 +716,7 @@ const Version = () => { alignItems: 'baseline' }} > - {data.partitions.length > 0 && data.developer_mode && ( + {otherPartitions.length > 0 && data.developer_mode && ( <> @@ -710,40 +724,36 @@ const Version = () => { - {data.partitions - .filter( - (partition) => partition.partition !== data.partition - ) - .map((partition) => ( - - {partition.version} - - setPartitionVersionInfo(partition.partition) - } - aria-label={LL.FIRMWARE_VERSION_INFO()} - > - - - - - ))} + {otherPartitions.map((partition) => ( + + {partition.version} + + setPartitionVersionInfo(partition.partition) + } + aria-label={LL.FIRMWARE_VERSION_INFO()} + > + + + + + ))} )} @@ -834,7 +844,6 @@ const Version = () => { loadData, LL, platform, - isDev, internetLive, latestVersion, latestDevVersion, @@ -848,7 +857,15 @@ const Version = () => { handleVersionInfoClose, closeInstallDialog, installFirmwareURL, - doRestart + doRestart, + otherPartitions, + setPartitionVersionInfo, + showPartitionDialog, + partitionVersion, + partition, + firmwareSize, + closeInstallPartitionDialog, + installPartitionFirmware ]); return {restarting ? : content};