feat: unauthenticated tab
This commit is contained in:
@@ -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,
|
||||
]}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user