From 1a8fb9f1b5a35311fdae2c500cdaabaace02bfb5 Mon Sep 17 00:00:00 2001 From: leon-morival Date: Mon, 17 Nov 2025 11:25:14 +0100 Subject: [PATCH] feat: confirm publish to youtube --- src/screens/Publishing/PublishYoutube.js | 24 ++++++++++++++++++++++-- src/screens/Writing/CreatingLyrics.js | 18 +++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/screens/Publishing/PublishYoutube.js b/src/screens/Publishing/PublishYoutube.js index b2ab1b7..0db7e93 100644 --- a/src/screens/Publishing/PublishYoutube.js +++ b/src/screens/Publishing/PublishYoutube.js @@ -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 = () => { {hasYoutubePublication && youtubeUrl && ( diff --git a/src/screens/Writing/CreatingLyrics.js b/src/screens/Writing/CreatingLyrics.js index 10bd25f..dd3789b 100644 --- a/src/screens/Writing/CreatingLyrics.js +++ b/src/screens/Writing/CreatingLyrics.js @@ -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);