feat: confirm publish to youtube
This commit is contained in:
@@ -6,6 +6,7 @@ import { background } from "../../assets";
|
|||||||
import BorderGradientButton from "../../components/BorderGradientButton";
|
import BorderGradientButton from "../../components/BorderGradientButton";
|
||||||
import GradientButton from "../../components/GradientButton";
|
import GradientButton from "../../components/GradientButton";
|
||||||
import MusicLandHeader from "../../components/MusicLandHeader";
|
import MusicLandHeader from "../../components/MusicLandHeader";
|
||||||
|
import alert from "../../components/Alert";
|
||||||
import firebase, { projectsRef, serverTimestamp } from "../../config/firebase";
|
import firebase, { projectsRef, serverTimestamp } from "../../config/firebase";
|
||||||
import Page from "../../layouts/Page";
|
import Page from "../../layouts/Page";
|
||||||
import { goBack } from "../../navigation/NavigationService";
|
import { goBack } from "../../navigation/NavigationService";
|
||||||
@@ -126,6 +127,25 @@ const PublishYoutube = () => {
|
|||||||
}
|
}
|
||||||
}, [playbackReady, projectId, setTooltip]);
|
}, [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 () => {
|
const handleResetPublication = useCallback(async () => {
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
setTooltip?.({
|
setTooltip?.({
|
||||||
@@ -228,8 +248,8 @@ const PublishYoutube = () => {
|
|||||||
<View style={{ gap: 14 }}>
|
<View style={{ gap: 14 }}>
|
||||||
<GradientButton
|
<GradientButton
|
||||||
title={publishButtonLabel}
|
title={publishButtonLabel}
|
||||||
onPress={handleMarkPublished}
|
onPress={handleConfirmPublish}
|
||||||
disabled={true}
|
disabled={publishDisabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{hasYoutubePublication && youtubeUrl && (
|
{hasYoutubePublication && youtubeUrl && (
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
});
|
});
|
||||||
const sanitizedStructure = sanitizeStructureList(
|
const sanitizedStructure = sanitizeStructureList(
|
||||||
config?.structure,
|
config?.structure,
|
||||||
CUSTOM_SANITIZE_OPTIONS,
|
CUSTOM_SANITIZE_OPTIONS
|
||||||
);
|
);
|
||||||
const callable = firebase
|
const callable = firebase
|
||||||
.functions()
|
.functions()
|
||||||
@@ -136,7 +136,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
const rawMessage = typeof e?.message === "string" ? e.message : "";
|
const rawMessage = typeof e?.message === "string" ? e.message : "";
|
||||||
const cleanedMessage = rawMessage.replace(
|
const cleanedMessage = rawMessage.replace(
|
||||||
/^functions error: \w+-\w+:\s*/i,
|
/^functions error: \w+-\w+:\s*/i,
|
||||||
"",
|
""
|
||||||
);
|
);
|
||||||
setError({
|
setError({
|
||||||
message:
|
message:
|
||||||
@@ -166,7 +166,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles");
|
console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles");
|
||||||
const sanitizedStructure = sanitizeStructureList(
|
const sanitizedStructure = sanitizeStructureList(
|
||||||
result?.structure || config?.structure,
|
result?.structure || config?.structure,
|
||||||
CUSTOM_SANITIZE_OPTIONS,
|
CUSTOM_SANITIZE_OPTIONS
|
||||||
);
|
);
|
||||||
const baseConfig =
|
const baseConfig =
|
||||||
config && typeof config === "object" && !Array.isArray(config)
|
config && typeof config === "object" && !Array.isArray(config)
|
||||||
@@ -192,12 +192,12 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
if ("customStructure" in persistedSelections) {
|
if ("customStructure" in persistedSelections) {
|
||||||
persistedSelections.customStructure = sanitizeStructureList(
|
persistedSelections.customStructure = sanitizeStructureList(
|
||||||
persistedSelections.customStructure,
|
persistedSelections.customStructure,
|
||||||
CUSTOM_SANITIZE_OPTIONS,
|
CUSTOM_SANITIZE_OPTIONS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ("parsedStructure" in persistedSelections) {
|
if ("parsedStructure" in persistedSelections) {
|
||||||
persistedSelections.parsedStructure = sanitizeStructureList(
|
persistedSelections.parsedStructure = sanitizeStructureList(
|
||||||
persistedSelections.parsedStructure,
|
persistedSelections.parsedStructure
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,14 +243,14 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
|
|
||||||
alert(
|
alert(
|
||||||
"Brief à reformuler",
|
"Brief à reformuler",
|
||||||
error.message,
|
__DEV__ ? error.message : "Une erreur s'est produite",
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: "OK",
|
text: "OK",
|
||||||
onPress: redirect,
|
onPress: redirect,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{ cancelable: false },
|
{ cancelable: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Platform.OS === "web") {
|
if (Platform.OS === "web") {
|
||||||
@@ -322,7 +322,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
setSaved(true);
|
setSaved(true);
|
||||||
await setIsLoading(true);
|
await setIsLoading(true);
|
||||||
console.log(
|
console.log(
|
||||||
"📄 [CreatingLyrics] Consultation manuelle du texte",
|
"📄 [CreatingLyrics] Consultation manuelle du texte"
|
||||||
);
|
);
|
||||||
await updateProjectData({
|
await updateProjectData({
|
||||||
title: result?.title || "",
|
title: result?.title || "",
|
||||||
@@ -337,7 +337,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
"⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle",
|
"⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle",
|
||||||
e,
|
e
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await setIsLoading(false);
|
await setIsLoading(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user