last tickets

This commit is contained in:
Thomas Demirdjian
2025-11-24 15:35:14 +01:00
parent 471a3177e8
commit 72852ad92b
40 changed files with 1749 additions and 667 deletions
+15 -18
View File
@@ -25,13 +25,7 @@ import { useGlobal } from "reactn";
import { background, icons } from "../../assets";
import PressableScale from "../../components/PressableScale";
import Slider from "../../components/Slider";
import {
arrayRemove,
arrayUnion,
increment,
projectsRef,
usersRef,
} from "../../config/firebase";
import { increment, projectsRef, usersRef } from "../../config/firebase";
import useDataFromRef from "../../hooks/useDataFromRef";
import usePlayer from "../../hooks/usePlayer";
import useTrackController from "../../hooks/useTrackController";
@@ -45,6 +39,11 @@ import {
createMusicSharePayload,
openShareSheet,
} from "../../utils/shareSheet";
import {
getProjectLikes,
LIKE_TARGET,
toggleProjectLike,
} from "../../utils/likes";
import {
formatStructureLabel,
getPromptLabelForStructure,
@@ -86,13 +85,10 @@ const MusicDetails = ({ route }) => {
});
useEffect(() => {
if (project && currentUID) {
const liked = Array.isArray(project?.likedBy)
? project.likedBy.includes(currentUID)
: false;
setFav(liked);
}
}, [project?.likedBy, currentUID]);
const likes = getProjectLikes(project, LIKE_TARGET.SONG);
const liked = currentUID ? likes.includes(currentUID) : false;
setFav(liked);
}, [currentUID, project]);
const title = project?.title || "Sans titre";
const artist = useMemo(() => {
@@ -862,10 +858,11 @@ const MusicDetails = ({ route }) => {
const next = !fav;
setFav(next);
try {
await projectsRef.doc(projectId).update({
likedBy: next
? arrayUnion(currentUID)
: arrayRemove(currentUID),
await toggleProjectLike({
projectId,
target: LIKE_TARGET.SONG,
currentUID,
next,
});
} catch (e) {
setFav(!next);