Skip to content

Commit

Permalink
support filesize in scene list (stashapp#4480)
Browse files Browse the repository at this point in the history
  • Loading branch information
cj12312021 authored and dogwithakeyboard committed Feb 18, 2024
1 parent 6453e6c commit 5708e88
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion ui/v2.5/src/components/Scenes/SceneListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
import * as GQL from "src/core/generated-graphql";
import NavUtils from "src/utils/navigation";
import TextUtils from "src/utils/text";
import { FormattedMessage, useIntl } from "react-intl";
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import SceneQueue from "src/models/sceneQueue";
Expand Down Expand Up @@ -168,6 +168,28 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
</ul>
);

function renderFileSize(file: { size: number | undefined }) {
const { size, unit } = TextUtils.fileSize(file.size);

return (
<FormattedNumber
value={size}
style="unit"
unit={unit}
unitDisplay="narrow"
maximumFractionDigits={2}
/>
);
}

const FileSizeCell = (scene: GQL.SlimSceneDataFragment) => (
<ul className="comma-list">
{scene.files.map((file) => (
<li key={file.id}>{renderFileSize(file)}</li>
))}
</ul>
);

const FrameRateCell = (scene: GQL.SlimSceneDataFragment) => (
<ul className="comma-list">
{scene.files.map((file) => (
Expand Down Expand Up @@ -320,6 +342,11 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
label: intl.formatMessage({ id: "resolution" }),
render: ResolutionCell,
},
{
value: "filesize",
label: intl.formatMessage({ id: "filesize" }),
render: FileSizeCell,
},
{
value: "framerate",
label: intl.formatMessage({ id: "framerate" }),
Expand Down

0 comments on commit 5708e88

Please sign in to comment.