Skip to content

Commit 91a3053

Browse files
authored
fix: settings page file size preview (#701)
1 parent 233c53f commit 91a3053

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

react/src/Settings.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,32 @@ export function EditableField(props) {
167167
/> {isCurrency ? 'atto' : 'bytes'}
168168
<div className="button" onClick={save}>Save</div>
169169
<div className="button cancel" onClick={cancel}>Cancel</div>
170-
{ BigInt(currentVal) > oneNanoFil ? (
171-
<span className="human">({humanFIL(BigInt(currentVal))})</span>
172-
) : null }
170+
<PreviewAmt currentVal={currentVal} isCurrency={isCurrency} />
173171
</td>
174172
) : (
175173
<td className="val" onClick={() => setEditing(true)}>
176174
{displayVal}
177175
<span className="edit" />
178-
{ BigInt(currentVal) > oneNanoFil ? (
179-
<span className="human">({humanFIL(BigInt(currentVal))})</span>
180-
) : null }
176+
{ isCurrency ? <PreviewAmt currentVal={currentVal} isCurrency={isCurrency} /> : null }
181177
</td>
182178
)}
183179
</tr>
184180
)
185181
}
186182

183+
function PreviewAmt({currentVal, isCurrency}) {
184+
if (isCurrency) {
185+
if (BigInt(currentVal) > oneNanoFil) {
186+
return <span className="human">({humanFIL(BigInt(currentVal))})</span>
187+
}
188+
} else {
189+
if (BigInt(currentVal) > BigInt(1024)) {
190+
return <span className="human">({humanFileSize(BigInt(currentVal))})</span>
191+
}
192+
}
193+
return null
194+
}
195+
187196
export function SettingsMenuItem(props) {
188197
return (
189198
<Link key="settings" className="menu-item" to="/settings">

0 commit comments

Comments
 (0)