fix: link provider

This commit is contained in:
2025-11-05 10:15:50 +01:00
parent 91818e58ec
commit 8180e0b375
5 changed files with 196 additions and 36 deletions
@@ -9,7 +9,6 @@ import React, {
import {
Image,
Pressable,
Share,
StyleSheet,
Text,
View,
@@ -30,6 +29,10 @@ import {
LIKE_TARGET,
toggleProjectLike,
} from "../../../utils/likes";
import {
createPlaybackSharePayload,
openShareSheet,
} from "../../../utils/shareSheet";
import { SheetManager } from "react-native-actions-sheet";
import { Feather } from "@expo/vector-icons";
@@ -254,6 +257,30 @@ const PlaybackItem = ({
const descriptionText =
item?.description || item?.title || "Description chanson";
const creatorName = useMemo(() => {
if (owner?.displayName) return owner.displayName;
if (owner?.artistName) return owner.artistName;
if (owner?.userName) return owner.userName;
if (typeof item?.userName === "string") return item.userName;
return "";
}, [item?.userName, owner?.artistName, owner?.displayName, owner?.userName]);
const sharePayload = useMemo(() => {
if (!item?.id) return null;
return createPlaybackSharePayload({
projectId: item.id,
title: typeof item?.title === "string" ? item.title.trim() : undefined,
artist: creatorName || undefined,
playbackUrl: videoUrl || undefined,
});
}, [creatorName, item?.id, item?.title, videoUrl]);
const handleShare = useCallback(() => {
if (sharePayload) {
openShareSheet(sharePayload);
}
}, [sharePayload]);
const handleReport = useCallback(() => {
if (!item?.id) return;
SheetManager.show("Report", {
@@ -481,18 +508,7 @@ const PlaybackItem = ({
)}
</Pressable>
<Pressable
onPress={async () => {
try {
const url = item?.playbackUrl || "";
const title = item?.title || "Partager";
const base = item?.title
? `Découvre « ${item.title} » sur MusicLand`
: `Découvre ce playback sur MusicLand`;
const message = url ? `${base}\n${url}` : base;
await Share.share({ message, title, url });
} catch (_e) {}
}}
onPress={handleShare}
style={[styles.actionButton, styles.actionSpacing]}
>
<Image