feat: Reduce memory footprint for PGlite, Implement user-specific Electric SQL database management

- Added cleanup logic for other users' databases on login to ensure data isolation.
- Introduced best-effort cleanup on logout to remove stale databases.
- Updated Electric client initialization to support user-specific databases.
- Refactored hooks to utilize the Electric context for better state management and prevent race conditions.
- Enhanced error handling and logging for Electric SQL operations.
This commit is contained in:
Anish Sarkar 2026-01-15 15:22:23 +05:30
parent eb1ddf0c92
commit 703ec08d19
9 changed files with 752 additions and 489 deletions

View file

@ -9,12 +9,20 @@ import { useAtomValue } from "jotai";
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
import { NotificationPopup } from "./NotificationPopup";
import { cn } from "@/lib/utils";
import { useParams } from "next/navigation";
export function NotificationButton() {
const { data: user } = useAtomValue(currentUserAtom);
const params = useParams();
const userId = user?.id ? String(user.id) : null;
// Get searchSpaceId from URL params - the component is rendered within /dashboard/[search_space_id]/
const searchSpaceId = params?.search_space_id
? Number(params.search_space_id)
: null;
const { notifications, unreadCount, loading, markAsRead, markAllAsRead } =
useNotifications(userId);
useNotifications(userId, searchSpaceId);
return (
<Popover>