refactor(web): byte unit utils (#10332)

refactor byte unit utils
This commit is contained in:
Daniel Dietzler
2024-06-14 19:27:46 +02:00
committed by GitHub
parent b4b654b53f
commit c896fe393f
15 changed files with 99 additions and 87 deletions

View File

@@ -13,13 +13,13 @@
import SettingInputField, {
SettingInputFieldType,
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
import { convertFromBytes, convertToBytes } from '$lib/utils/byte-converter';
import { ByteUnit, convertFromBytes, convertToBytes } from '$lib/utils/byte-units';
let archiveSize = convertFromBytes($preferences?.download?.archiveSize || 4, 'GiB');
let archiveSize = convertFromBytes($preferences?.download?.archiveSize || 4, ByteUnit.GiB);
const handleSave = async () => {
try {
const dto = { download: { archiveSize: Math.floor(convertToBytes(archiveSize, 'GiB')) } };
const dto = { download: { archiveSize: Math.floor(convertToBytes(archiveSize, ByteUnit.GiB)) } };
const newPreferences = await updateMyPreferences({ userPreferencesUpdateDto: dto });
$preferences = newPreferences;