new song structure

This commit is contained in:
2025-10-21 11:38:48 +02:00
parent 59328aaaed
commit 3a5d449424
11 changed files with 807 additions and 175 deletions
+36 -11
View File
@@ -10,6 +10,7 @@ import { Routes } from "../../navigation";
import { goBack, navigate } from "../../navigation/NavigationService";
import { useUser } from "../../providers/UserDataProvider";
import { gutters } from "../../styles";
import { sanitizeStructureList } from "../../utils/songStructure";
import CreatingLyrics from "./CreatingLyrics";
import CustomizeSongStructure from "./CustomizeSongStructure";
import EmotionConvey from "./EmotionConvey";
@@ -138,11 +139,24 @@ const CreateLyricsWithAi = () => {
// Structure personnalisée: prioriser selections.customStructure puis config.structure
const savedCustom = Array.isArray(sel.customStructure)
? sel.customStructure
? sanitizeStructureList(sel.customStructure)
: null;
const cfgStructure = Array.isArray(cfg.structure) ? cfg.structure : null;
if (!Array.isArray(customStructure) && (savedCustom || cfgStructure)) {
setCustomStructure(savedCustom || cfgStructure);
const cfgStructure = Array.isArray(cfg.structure)
? sanitizeStructureList(cfg.structure)
: null;
const fallbackStructure =
savedCustom && savedCustom.length ? savedCustom : cfgStructure;
if (!Array.isArray(customStructure) && fallbackStructure?.length) {
setCustomStructure(fallbackStructure);
} else if (
Array.isArray(customStructure) &&
fallbackStructure?.length &&
(customStructure.length !== fallbackStructure.length ||
customStructure.some(
(value, idx) => value !== fallbackStructure[idx]
))
) {
setCustomStructure(fallbackStructure);
}
}, [selectedProject]);
@@ -172,7 +186,8 @@ const CreateLyricsWithAi = () => {
for (let i = 0; i < count; i++) result.push("refrain");
}
});
return result.length ? result : null;
const sanitizedResult = sanitizeStructureList(result);
return sanitizedResult.length ? sanitizedResult : null;
} catch (e) {
return null;
}
@@ -192,6 +207,13 @@ const CreateLyricsWithAi = () => {
const resolvedStyle = shouldUseOtherStyle
? persistedOtherStyle || undefined
: style || undefined;
const sanitizedCustom =
Array.isArray(customStructure) && customStructure.length > 0
? sanitizeStructureList(customStructure)
: [];
const sanitizedParsed = Array.isArray(parsedStructure)
? sanitizeStructureList(parsedStructure)
: [];
return {
objective: resolvedObjective,
@@ -203,9 +225,11 @@ const CreateLyricsWithAi = () => {
style: resolvedStyle,
audience: audience?.trim() ? audience.trim() : undefined,
structure:
(Array.isArray(customStructure) && customStructure.length > 0
? customStructure
: parsedStructure) || undefined,
sanitizedCustom.length > 0
? sanitizedCustom
: sanitizedParsed.length > 0
? sanitizedParsed
: undefined,
rhymes: rhymes || undefined,
};
}, [
@@ -281,12 +305,13 @@ const CreateLyricsWithAi = () => {
// Si l'utilisateur a déjà des paroles et vient de finir CustomizeSongStructure (index 6),
// sauter Rhymes et CreatingLyrics et aller directement sur Lyrics
if (hasLyrics && selectedIndex === 6) {
const chosenStructure =
const chosenStructure = sanitizeStructureList(
Array.isArray(customStructure) && customStructure.length > 0
? customStructure
: Array.isArray(parsedStructure)
? parsedStructure
: [];
: []
);
await updateProjectData({
config: { structure: chosenStructure },
selections: {
@@ -299,7 +324,7 @@ const CreateLyricsWithAi = () => {
audience,
structure,
parsedStructure,
customStructure,
customStructure: sanitizeStructureList(customStructure),
rhymes,
},
hasLyrics: true,