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

fix file size display from kB to KB #10561

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/structures/UploadBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class UploadBar extends React.PureComponent<IProps, IState> {
count: this.state.countFiles - 1,
});

const uploadSize = filesize(this.state.currentTotal!);
const uploadSize = filesize(this.state.currentTotal!, { base: 2, standard: "jedec" });
return (
<div className="mx_UploadBar">
<div className="mx_UploadBar_filename">
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/dialogs/UploadConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
{preview && <div>{preview}</div>}
<div id={fileId}>
{placeholder}
{this.props.file.name} ({filesize(this.props.file.size)})
{this.props.file.name} ({filesize(this.props.file.size, { base: 2, standard: "jedec" })}
)
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/views/dialogs/UploadFailureDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default class UploadFailureDialog extends React.Component<IProps> {
"This file is <b>too large</b> to upload. " +
"The file size limit is %(limit)s but this file is %(sizeOfThisFile)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
sizeOfThisFile: filesize(this.props.badFiles[0].size),
limit: filesize(this.props.contentMessages.getUploadLimit(), { base: 2, standard: "jedec" }),
sizeOfThisFile: filesize(this.props.badFiles[0].size, { base: 2, standard: "jedec" }),
},
{
b: (sub) => <b>{sub}</b>,
Expand All @@ -71,7 +71,7 @@ export default class UploadFailureDialog extends React.Component<IProps> {
message = _t(
"These files are <b>too large</b> to upload. " + "The file size limit is %(limit)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
limit: filesize(this.props.contentMessages.getUploadLimit(), { base: 2, standard: "jedec" }),
},
{
b: (sub) => <b>{sub}</b>,
Expand All @@ -89,7 +89,7 @@ export default class UploadFailureDialog extends React.Component<IProps> {
message = _t(
"Some files are <b>too large</b> to be uploaded. " + "The file size limit is %(limit)s.",
{
limit: filesize(this.props.contentMessages.getUploadLimit()),
limit: filesize(this.props.contentMessages.getUploadLimit(), { base: 2, standard: "jedec" }),
},
{
b: (sub) => <b>{sub}</b>,
Expand Down
4 changes: 3 additions & 1 deletion src/components/views/messages/MFileBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ export default class MFileBody extends React.Component<IProps, IState> {
</a>
{this.context.timelineRenderingType === TimelineRenderingType.File && (
<div className="mx_MImageBody_size">
{this.content.info?.size ? filesize(this.content.info.size) : ""}
{this.content.info?.size
? filesize(this.content.info.size, { base: 2, standard: "jedec" })
: ""}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function presentableTextForFile(
// it since it is "ugly", users generally aren't aware what it
// means and the type of the attachment can usually be inferred
// from the file extension.
text += " (" + <string>filesize(content.info.size) + ")";
text += " (" + <string>filesize(content.info.size, { base: 2, standard: "jedec" }) + ")";
}
return text;
}