notifications

This commit is contained in:
2025-10-07 16:18:05 +02:00
parent b508857000
commit a4dca1d4f0
10 changed files with 499 additions and 4 deletions
+12
View File
@@ -100,6 +100,7 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => {
// Follow state derived from owner.followedBy
const [isFollowing, setIsFollowing] = useState(false);
const [isFollowActionPending, setIsFollowActionPending] = useState(false);
useEffect(() => {
const list = Array.isArray(owner?.followedBy) ? owner.followedBy : [];
setIsFollowing(currentUID ? list.includes(currentUID) : false);
@@ -278,9 +279,14 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => {
</Pressable>
{owner?.id && currentUID && owner.id !== currentUID && (
<Pressable
disabled={isFollowActionPending}
onPress={async () => {
if (isFollowActionPending) return;
try {
setIsFollowActionPending(true);
const next = !isFollowing;
console.log("follwin");
setIsFollowing(next);
// Optimistic update of local owner.followedBy
setOwner((prev) => {
@@ -294,9 +300,15 @@ const PlaybackItem = ({ item, isActive, userCache, getUserByUid }) => {
});
if (next) await followUser?.(owner.id);
else await unfollowUser?.(owner.id);
// Timeout de 2 secondes avant de pouvoir recliquer
global.setTimeout(() => {
setIsFollowActionPending(false);
}, 1000);
} catch (e) {
// rollback on failure
setIsFollowing((v) => !v);
setIsFollowActionPending(false);
}
}}
>