mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-02-20 15:11:06 -08:00
refactor: updater now use i18n message
This commit is contained in:
parent
02cbc58370
commit
55506c32e5
2 changed files with 1 additions and 25 deletions
|
|
@ -1,4 +1,5 @@
|
|||
/**
|
||||
* Used to be in updater to show download progress.
|
||||
* https://stackoverflow.com/a/18650828
|
||||
*/
|
||||
export default function formatBytes(bytes: number, decimals = 2): string {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { useState } from 'react';
|
||||
import { useObservable } from 'beautiful-react-hooks';
|
||||
|
||||
import formatBytes from '@services/libs/formatBytes';
|
||||
import { IUpdaterMetaData } from './interface';
|
||||
|
||||
export function useUpdaterObservable(): IUpdaterMetaData | undefined {
|
||||
|
|
@ -9,27 +8,3 @@ export function useUpdaterObservable(): IUpdaterMetaData | undefined {
|
|||
useObservable(window.observables.updater.updaterMetaData$, updaterMetaDataSetter as any);
|
||||
return updaterMetaData;
|
||||
}
|
||||
|
||||
export function getUpdaterDesc(status: IUpdaterMetaData['status'], info: IUpdaterMetaData['info']): string {
|
||||
if (info instanceof Error) {
|
||||
return info.message;
|
||||
}
|
||||
if (status === 'download-progress') {
|
||||
if (info !== undefined && 'transferred' in info) {
|
||||
const { transferred, total, bytesPerSecond } = info;
|
||||
return `Downloading updates (${formatBytes(transferred)}/${formatBytes(total)} at ${formatBytes(bytesPerSecond)}/s)...`;
|
||||
}
|
||||
return 'Downloading updates...';
|
||||
}
|
||||
if (status === 'checking-for-update') {
|
||||
return 'Checking for updates...';
|
||||
}
|
||||
if (status === 'update-available') {
|
||||
return 'Downloading updates...';
|
||||
}
|
||||
if (status === 'update-downloaded') {
|
||||
if (info !== undefined && 'version' in info) return `A new version (${info.version}) has been downloaded.`;
|
||||
return 'A new version has been downloaded.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue