feat: confirm publish to youtube

This commit is contained in:
2025-11-17 11:25:14 +01:00
parent d2094b453e
commit 1a8fb9f1b5
2 changed files with 31 additions and 11 deletions
+22 -2
View File
@@ -6,6 +6,7 @@ import { background } from "../../assets";
import BorderGradientButton from "../../components/BorderGradientButton";
import GradientButton from "../../components/GradientButton";
import MusicLandHeader from "../../components/MusicLandHeader";
import alert from "../../components/Alert";
import firebase, { projectsRef, serverTimestamp } from "../../config/firebase";
import Page from "../../layouts/Page";
import { goBack } from "../../navigation/NavigationService";
@@ -126,6 +127,25 @@ const PublishYoutube = () => {
}
}, [playbackReady, projectId, setTooltip]);
const handleConfirmPublish = useCallback(() => {
if (publishDisabled) {
return;
}
const confirmTitle = hasYoutubePublication
? "Confirmer la mise à jour"
: "Confirmer la publication";
const confirmDescription = hasYoutubePublication
? "La vidéo existe déjà sur YouTube. Confirme que tu souhaites remplacer la version publiée."
: "Confirme que tu souhaites publier ce playback sur la chaîne YouTube MusicLand. Il sera visible publiquement.";
alert(confirmTitle, confirmDescription, [
{ text: "Annuler", style: "cancel" },
{
text: hasYoutubePublication ? "Mettre à jour" : "Je confirme",
onPress: handleMarkPublished,
},
]);
}, [handleMarkPublished, hasYoutubePublication, publishDisabled]);
const handleResetPublication = useCallback(async () => {
if (!projectId) {
setTooltip?.({
@@ -228,8 +248,8 @@ const PublishYoutube = () => {
<View style={{ gap: 14 }}>
<GradientButton
title={publishButtonLabel}
onPress={handleMarkPublished}
disabled={true}
onPress={handleConfirmPublish}
disabled={publishDisabled}
/>
{hasYoutubePublication && youtubeUrl && (
+9 -9
View File
@@ -73,7 +73,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
});
const sanitizedStructure = sanitizeStructureList(
config?.structure,
CUSTOM_SANITIZE_OPTIONS,
CUSTOM_SANITIZE_OPTIONS
);
const callable = firebase
.functions()
@@ -136,7 +136,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
const rawMessage = typeof e?.message === "string" ? e.message : "";
const cleanedMessage = rawMessage.replace(
/^functions error: \w+-\w+:\s*/i,
"",
""
);
setError({
message:
@@ -166,7 +166,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles");
const sanitizedStructure = sanitizeStructureList(
result?.structure || config?.structure,
CUSTOM_SANITIZE_OPTIONS,
CUSTOM_SANITIZE_OPTIONS
);
const baseConfig =
config && typeof config === "object" && !Array.isArray(config)
@@ -192,12 +192,12 @@ const CreatingLyrics = ({ active, config, selections }) => {
if ("customStructure" in persistedSelections) {
persistedSelections.customStructure = sanitizeStructureList(
persistedSelections.customStructure,
CUSTOM_SANITIZE_OPTIONS,
CUSTOM_SANITIZE_OPTIONS
);
}
if ("parsedStructure" in persistedSelections) {
persistedSelections.parsedStructure = sanitizeStructureList(
persistedSelections.parsedStructure,
persistedSelections.parsedStructure
);
}
}
@@ -243,14 +243,14 @@ const CreatingLyrics = ({ active, config, selections }) => {
alert(
"Brief à reformuler",
error.message,
__DEV__ ? error.message : "Une erreur s'est produite",
[
{
text: "OK",
onPress: redirect,
},
],
{ cancelable: false },
{ cancelable: false }
);
if (Platform.OS === "web") {
@@ -322,7 +322,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
setSaved(true);
await setIsLoading(true);
console.log(
"📄 [CreatingLyrics] Consultation manuelle du texte",
"📄 [CreatingLyrics] Consultation manuelle du texte"
);
await updateProjectData({
title: result?.title || "",
@@ -337,7 +337,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
} catch (e) {
console.error(
"⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle",
e,
e
);
} finally {
await setIsLoading(false);