diff --git a/client/src/javascript/components/general/Duration.tsx b/client/src/javascript/components/general/Duration.tsx index 0b0cdac1..5791b720 100644 --- a/client/src/javascript/components/general/Duration.tsx +++ b/client/src/javascript/components/general/Duration.tsx @@ -1,17 +1,17 @@ import {FormattedMessage} from 'react-intl'; import * as React from 'react'; -import type {Duration as DurationType} from '@shared/types/Torrent'; +import formatUtil from '@shared/util/formatUtil'; interface DurationProps { suffix?: React.ReactNode; - value: -1 | DurationType; + value: number; } const Duration: React.FC = (props: DurationProps) => { - const {suffix, value: duration} = props; + const {suffix, value} = props; - if (duration == null) { + if (value == null) { return null; } @@ -22,6 +22,8 @@ const Duration: React.FC = (props: DurationProps) => { suffixElement = {suffix}; } + const duration = value === -1 ? -1 : formatUtil.secondsToDuration(value); + if (duration === -1) { content = ; } else if (duration.years != null && duration.years > 0) { diff --git a/client/src/javascript/components/sidebar/TransferRateDetails.tsx b/client/src/javascript/components/sidebar/TransferRateDetails.tsx index e5efcc6e..0840a72a 100644 --- a/client/src/javascript/components/sidebar/TransferRateDetails.tsx +++ b/client/src/javascript/components/sidebar/TransferRateDetails.tsx @@ -3,7 +3,6 @@ import {Component} from 'react'; import {defineMessages, injectIntl, WrappedComponentProps} from 'react-intl'; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration'; -import formatUtil from '@shared/util/formatUtil'; import {observer} from 'mobx-react'; import type {TransferDirection} from '@shared/types/TransferData'; @@ -71,14 +70,12 @@ class TransferRateDetails extends Component { }); if (inspectorPoint?.nearestTimestamp != null) { - const currentTime = dayjs(Date.now()); - const durationSummary = formatUtil.secondsToDuration( - dayjs.duration(currentTime.diff(dayjs(inspectorPoint.nearestTimestamp))).asSeconds(), - ); - timestamp = (
- +
); } diff --git a/client/src/javascript/util/sortTorrents.ts b/client/src/javascript/util/sortTorrents.ts index 2536530f..4fe11ad6 100644 --- a/client/src/javascript/util/sortTorrents.ts +++ b/client/src/javascript/util/sortTorrents.ts @@ -27,7 +27,7 @@ function sortTorrents(torrents: Array, sortBy: Readonly 0) { - return formatUtil.secondsToDuration((sizeBytes - bytesDone) / downRate); + return (sizeBytes - bytesDone) / downRate; } return -1; diff --git a/shared/types/Torrent.ts b/shared/types/Torrent.ts index 6ef93f17..e894369a 100644 --- a/shared/types/Torrent.ts +++ b/shared/types/Torrent.ts @@ -36,7 +36,8 @@ export interface TorrentProperties { directory: string; downRate: number; downTotal: number; - eta: -1 | Duration; + // Torrent ETA (seconds), -1 means infinity + eta: number; hash: string; isMultiFile: boolean; isPrivate: boolean;