Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
fix pretty bytes with NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
mgilangjanuar committed Jan 5, 2022
1 parent 5935d91 commit 32a642c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions web/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Settings: React.FC<Props> = ({ me, mutate, error }) => {
// })

const save = (settings: any) => {
req.patch('/users/me/settings', { settings })
return req.patch('/users/me/settings', { settings })
.then(() => {
notification.success({ message: 'Settings saved' })
// setExpandableRows(!expandableRows)
Expand Down Expand Up @@ -92,8 +92,7 @@ const Settings: React.FC<Props> = ({ me, mutate, error }) => {
</Form.Item>
<Form.Item label="Dark Mode" name="expandable_rows">
<Switch onChange={val => {
save({ theme: val ? 'dark' : 'light' })
return window.location.reload()
return save({ theme: val ? 'dark' : 'light' }).then(window.location.reload)
}} checked={me?.user.settings?.theme === 'dark'} defaultChecked={me?.user.settings?.theme === 'dark'} />
</Form.Item>
<Form.Item label="Check Updates">
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Navbar: React.FC<Props> = ({ user, page }) => {
<Popover placement="bottomRight" trigger={['click']} content={<div>
<div style={{ padding: '10px' }}>
Bandwidth usage: { }
{user?.plan === 'premium' ? <Tag color="green">Unlimited</Tag> : <Tooltip placement="left" title={<>You can download up to {prettyBytes(Math.max(0, 1_500_000_000 - Number(usage?.usage.usage)))} until {moment(usage?.usage.expire).local().format('lll')}</>}>
{user?.plan === 'premium' ? <Tag color="green">Unlimited</Tag> : <Tooltip placement="left" title={<>You can download up to {prettyBytes(Math.max(0, 1_500_000_000 - Number(usage?.usage.usage) || 0))} until {moment(usage?.usage.expire).local().format('lll')}</>}>
<Progress status="exception" percent={Number((Number(usage?.usage.usage || 0) / 1_500_000_000 * 100).toFixed(1))} />
</Tooltip>}
</div>
Expand Down

0 comments on commit 32a642c

Please sign in to comment.