feat: add feed
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
} from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useAuth } from "@/components/auth/auth-provider";
|
||||
import { notifications } from "@/lib/social";
|
||||
import { feed, notifications } from "@/lib/social";
|
||||
import { sadhna } from "@/lib/sadhna";
|
||||
|
||||
type NotificationsContextValue = {
|
||||
@@ -113,8 +113,24 @@ export function NotificationsProvider({
|
||||
}
|
||||
}, [user?.id]);
|
||||
|
||||
// Open the realtime connection while signed in.
|
||||
const userId = user?.id;
|
||||
|
||||
// When the session ends — the page unloads / the realtime socket drops as
|
||||
// the user navigates away or closes the tab — clear the home-feed seen-set
|
||||
// so it doesn't linger in Redis. `keepalive` lets the request outlive the
|
||||
// page. (Genuine network drops with no unload are caught by the set's TTL;
|
||||
// we deliberately don't clear on transient socket blips, which would re-show
|
||||
// posts mid-scroll.)
|
||||
useEffect(() => {
|
||||
if (!userId) return;
|
||||
const onLeave = () => {
|
||||
void feed.reset().catch(() => {});
|
||||
};
|
||||
window.addEventListener("pagehide", onLeave);
|
||||
return () => window.removeEventListener("pagehide", onLeave);
|
||||
}, [userId]);
|
||||
|
||||
// Open the realtime connection while signed in.
|
||||
useEffect(() => {
|
||||
if (!userId) return;
|
||||
const key = process.env.NEXT_PUBLIC_SOKETI_KEY;
|
||||
|
||||
Reference in New Issue
Block a user