diff options
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/components/views/app-upgrade/components/download-progress/hooks/useMessage/hooks/useGetMessageTimeLeft.ts | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/views/app-upgrade/components/download-progress/hooks/useMessage/hooks/useGetMessageTimeLeft.ts b/desktop/packages/mullvad-vpn/src/renderer/components/views/app-upgrade/components/download-progress/hooks/useMessage/hooks/useGetMessageTimeLeft.ts index ee2bd530d5..0052b9a80c 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/components/views/app-upgrade/components/download-progress/hooks/useMessage/hooks/useGetMessageTimeLeft.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/components/views/app-upgrade/components/download-progress/hooks/useMessage/hooks/useGetMessageTimeLeft.ts @@ -1,6 +1,7 @@ import { sprintf } from 'sprintf-js'; import { messages } from '../../../../../../../../../shared/gettext'; +import { isNumber } from '../../../../../../../../../shared/utils'; import { useAppUpgradeEvent } from '../../../../../../../../redux/hooks'; export const useGetMessageTimeLeft = () => { @@ -9,30 +10,33 @@ export const useGetMessageTimeLeft = () => { const getMessageTimeLeft = () => { if (appUpgradeEvent?.type === 'APP_UPGRADE_STATUS_DOWNLOAD_PROGRESS') { const { timeLeft } = appUpgradeEvent; + const isTimeLeftNumeric = isNumber(timeLeft); - if (timeLeft > 90) { - const minutes = Math.round(timeLeft / 60); + if (isTimeLeftNumeric) { + if (timeLeft > 90) { + const minutes = Math.round(timeLeft / 60); + + return sprintf( + // TRANSLATORS: Status text displayed below a progress bar when the update is being downloaded + // TRANSLATORS: Available placeholders: + // TRANSLATORS: %(minutes)s - Will be replaced with remaining minutes until download is complete + messages.pgettext('app-upgrade-view', 'About %(minutes)s minutes remaining...'), + { + minutes, + }, + ); + } return sprintf( // TRANSLATORS: Status text displayed below a progress bar when the update is being downloaded // TRANSLATORS: Available placeholders: - // TRANSLATORS: %(minutes)s - Will be replaced with remaining minutes until download is complete - messages.pgettext('app-upgrade-view', 'About %(minutes)s minutes remaining...'), + // TRANSLATORS: %(second)s - Will be replaced with remaining seconds until download is complete + messages.pgettext('app-upgrade-view', 'About %(seconds)s seconds remaining...'), { - minutes, + seconds: timeLeft, }, ); } - - return sprintf( - // TRANSLATORS: Status text displayed below a progress bar when the update is being downloaded - // TRANSLATORS: Available placeholders: - // TRANSLATORS: %(second)s - Will be replaced with remaining seconds until download is complete - messages.pgettext('app-upgrade-view', 'About %(seconds)s seconds remaining...'), - { - seconds: timeLeft, - }, - ); } return null; |
