last tickets
This commit is contained in:
@@ -4,7 +4,7 @@ import { Image, Pressable, StyleSheet, Text, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { icons, img } from "../../assets";
|
||||
import { arrayRemove, arrayUnion, projectsRef } from "../../config/firebase";
|
||||
import { projectsRef } from "../../config/firebase";
|
||||
import useDataFromRef from "../../hooks/useDataFromRef";
|
||||
import { isWeb } from "../../hooks/useLayoutType";
|
||||
import usePlayer from "../../hooks/usePlayer";
|
||||
@@ -13,6 +13,11 @@ import { useUser } from "../../providers/UserDataProvider";
|
||||
import { gutters, Palette } from "../../styles";
|
||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||
import { ensureAuthenticated } from "../../utils/authRedirect";
|
||||
import {
|
||||
getProjectLikes,
|
||||
LIKE_TARGET,
|
||||
toggleProjectLike,
|
||||
} from "../../utils/likes";
|
||||
import { responsiveHeight } from "react-native-responsive-dimensions";
|
||||
|
||||
const formatDuration = (ms) => {
|
||||
@@ -60,9 +65,9 @@ const GlobalAudioPlayer = () => {
|
||||
refreshArray: [projectId],
|
||||
});
|
||||
|
||||
const likedByList = Array.isArray(projectData?.likedBy)
|
||||
? projectData.likedBy
|
||||
: [];
|
||||
const likedByList = useMemo(() => {
|
||||
return getProjectLikes(projectData, LIKE_TARGET.SONG);
|
||||
}, [projectData]);
|
||||
|
||||
const likedFromDoc = useMemo(() => {
|
||||
if (!projectId || !currentUID) return false;
|
||||
@@ -100,12 +105,12 @@ const GlobalAudioPlayer = () => {
|
||||
const next = !effectiveIsLiked;
|
||||
setPendingLike(next);
|
||||
try {
|
||||
await projectsRef.doc(projectId).set(
|
||||
{
|
||||
likedBy: next ? arrayUnion(currentUID) : arrayRemove(currentUID),
|
||||
},
|
||||
{ merge: true },
|
||||
);
|
||||
await toggleProjectLike({
|
||||
projectId,
|
||||
target: LIKE_TARGET.SONG,
|
||||
currentUID,
|
||||
next,
|
||||
});
|
||||
} catch (_error) {
|
||||
setPendingLike(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user