CODEX - Probably fixed the download buttons
This commit is contained in:
@@ -532,8 +532,13 @@ export default function MelodyDetail() {
|
||||
</Field>
|
||||
<Field label="Binary File">
|
||||
{(() => {
|
||||
// Prefer the uploaded file URL, fall back to melody.url (legacy/firebase storage URL)
|
||||
const binaryUrl = normalizeFileUrl(files.binary_url || melody.url || null);
|
||||
// Common source of truth: assigned archetype binary first, then melody URL, then uploaded file URL.
|
||||
const binaryUrl = normalizeFileUrl(
|
||||
(builtMelody?.binary_url ? `/api${builtMelody.binary_url}` : null) ||
|
||||
melody.url ||
|
||||
files.binary_url ||
|
||||
null
|
||||
);
|
||||
if (!binaryUrl) return <span style={{ color: "var(--text-muted)" }}>Not uploaded</span>;
|
||||
|
||||
const binaryPid = builtMelody?.pid || melody.pid || "binary";
|
||||
@@ -541,7 +546,7 @@ export default function MelodyDetail() {
|
||||
|
||||
// Derive a display name: for firebase URLs extract the filename portion
|
||||
let downloadName = binaryFilename;
|
||||
if (!files.binary_url && melody.url) {
|
||||
if (!builtMelody?.binary_url && !files.binary_url && melody.url) {
|
||||
try {
|
||||
const urlPath = decodeURIComponent(new URL(melody.url).pathname);
|
||||
const parts = urlPath.split("/");
|
||||
@@ -577,7 +582,7 @@ export default function MelodyDetail() {
|
||||
a.click();
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
window.open(binaryUrl, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -607,6 +612,9 @@ export default function MelodyDetail() {
|
||||
>
|
||||
View
|
||||
</button>
|
||||
<span className="text-xs" style={{ color: "var(--text-muted)" }}>
|
||||
{info.totalNotes ?? 0} active notes
|
||||
</span>
|
||||
{!files.binary_url && melody.url && (
|
||||
<span className="text-xs px-1.5 py-0.5 rounded" style={{ backgroundColor: "var(--bg-card-hover)", color: "var(--text-muted)" }}>
|
||||
via URL
|
||||
@@ -626,9 +634,6 @@ export default function MelodyDetail() {
|
||||
</a>
|
||||
</span>
|
||||
)}
|
||||
<span className="text-xs" style={{ color: "var(--text-muted)" }}>
|
||||
{info.totalNotes ?? 0} active notes
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
})()}
|
||||
|
||||
Reference in New Issue
Block a user