feat: unauthenticated tab

This commit is contained in:
2025-11-05 10:58:34 +01:00
parent 8180e0b375
commit e8db8d1654
15 changed files with 229 additions and 58 deletions
+31 -18
View File
@@ -12,6 +12,7 @@ import useNavigateToMusicDetails from "../../hooks/useNavigateToMusicDetails";
import { useUser } from "../../providers/UserDataProvider";
import { gutters, Palette } from "../../styles";
import { FONT_FAMILY } from "../../styles/Fonts";
import { ensureAuthenticated } from "../../utils/authRedirect";
const formatDuration = (ms) => {
const totalSeconds = Math.max(0, Math.floor((ms || 0) / 1000));
@@ -82,22 +83,34 @@ const GlobalAudioPlayer = () => {
}
}, [pendingLike, likedFromDoc]);
const handleToggleLike = useCallback(async (event) => {
event?.stopPropagation?.();
if (!projectId || !currentUID || isLikeProcessing) return;
const next = !effectiveIsLiked;
setPendingLike(next);
try {
await projectsRef.doc(projectId).set(
{
likedBy: next ? arrayUnion(currentUID) : arrayRemove(currentUID),
},
{ merge: true }
);
} catch (_error) {
setPendingLike(null);
}
}, [currentUID, effectiveIsLiked, isLikeProcessing, projectId]);
const handleToggleLike = useCallback(
async (event) => {
event?.stopPropagation?.();
if (!projectId || isLikeProcessing) return;
if (
!ensureAuthenticated(currentUID, {
onIntercept: () => {
setPendingLike(null);
},
})
) {
return;
}
const next = !effectiveIsLiked;
setPendingLike(next);
try {
await projectsRef.doc(projectId).set(
{
likedBy: next ? arrayUnion(currentUID) : arrayRemove(currentUID),
},
{ merge: true }
);
} catch (_error) {
setPendingLike(null);
}
},
[currentUID, effectiveIsLiked, isLikeProcessing, projectId]
);
const insets = useSafeAreaInsets();
@@ -199,11 +212,11 @@ const GlobalAudioPlayer = () => {
<Pressable
onPress={handleToggleLike}
hitSlop={12}
disabled={!projectId || !currentUID || isLikeProcessing}
disabled={!projectId || isLikeProcessing}
style={[
styles.actionButton,
styles.likeButton,
(!projectId || !currentUID || isLikeProcessing) &&
(!projectId || isLikeProcessing) &&
styles.disabledAction,
]}
>