feat: media & music file name

This commit is contained in:
2026-06-07 21:53:01 +03:30
parent 2be0f3e2b8
commit 944d3bc00a
3 changed files with 24 additions and 4 deletions
+7 -2
View File
@@ -18,7 +18,7 @@ import {
Badge,
} from "@/components/ui";
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
import { formatMinutes } from "@/lib/utils";
import { formatMinutes, fileNameToTitle } from "@/lib/utils";
import { MediaPreview } from "@/components/MediaPreview";
import { ImagePicker } from "@/components/ImagePicker";
import { pickUrl, SOUND_KEYS, VIDEO_KEYS, IMAGE_KEYS } from "@/lib/media";
@@ -397,7 +397,12 @@ export default function MediaPage() {
<Input
type="file"
accept="audio/*,video/*"
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
onChange={(e) => {
const f = e.target.files?.[0] ?? null;
setFile(f);
// Fill the title from the file name if still empty.
if (f && !title.trim()) setTitle(fileNameToTitle(f.name));
}}
/>
</Field>
+7 -2
View File
@@ -15,7 +15,7 @@ import {
PageHeader,
} from "@/components/ui";
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
import { formatMinutes } from "@/lib/utils";
import { formatMinutes, fileNameToTitle } from "@/lib/utils";
import { MediaPreview } from "@/components/MediaPreview";
import { ImagePicker } from "@/components/ImagePicker";
import { pickUrl, SOUND_KEYS, IMAGE_KEYS } from "@/lib/media";
@@ -301,7 +301,12 @@ export default function MusicTracksPage() {
<Input
type="file"
accept="audio/*"
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
onChange={(e) => {
const f = e.target.files?.[0] ?? null;
setFile(f);
// Fill the title from the file name if still empty.
if (f && !title.trim()) setTitle(fileNameToTitle(f.name));
}}
required={!editing}
/>
</Field>