From f8296831fc2dfabadc517a9448eca7a64ad5d609 Mon Sep 17 00:00:00 2001 From: Christopher Maujean Date: Wed, 30 Jul 2025 08:48:57 -0700 Subject: [PATCH] remove the datacontext, we will useResource and other tools directly from LDO --- CLAUDE.md | 2 ++ src/App.tsx | 61 ++++++++++++++++------------------ src/contexts/DataContext.ts | 12 ------- src/hooks/useData.ts | 10 ------ src/providers/DataProvider.tsx | 49 --------------------------- 5 files changed, 31 insertions(+), 103 deletions(-) delete mode 100644 src/contexts/DataContext.ts delete mode 100644 src/hooks/useData.ts delete mode 100644 src/providers/DataProvider.tsx diff --git a/CLAUDE.md b/CLAUDE.md index 4fca865..3f83c5a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,6 +27,8 @@ This is a React/TypeScript NAO (Network of Authentic Others) community managemen - Always completely implement any functionality as requested. - Do not hallucinate, or pretend - Always use the most up to date official documentation for libraries or techniques +- prefer zustand stores above useState +- use LDO and nextgraphauth.session for persistent data (contacts for example) consider this to be our "database" # Code Style - Use react hooks: useMemo, useCallback, and other standard hooks diff --git a/src/App.tsx b/src/App.tsx index cb15496..fd3c165 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,6 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { ThemeProvider } from '@mui/material/styles'; import CssBaseline from '@mui/material/CssBaseline'; import { OnboardingProvider } from '@/contexts/OnboardingContext'; -import { DataProvider } from '@/providers/DataProvider'; import { BrowserNGLdoProvider, useNextGraphAuth } from '@/lib/nextgraph'; import type { NextGraphAuth } from '@/types/nextgraph'; import DashboardLayout from '@/components/layout/DashboardLayout'; @@ -39,37 +38,35 @@ const AppContent = () => { } return ( - - - - - } /> - } /> - - - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - - } /> - - - - + + + + } /> + } /> + + + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + } /> + + + ); }; diff --git a/src/contexts/DataContext.ts b/src/contexts/DataContext.ts deleted file mode 100644 index 09f3bc8..0000000 --- a/src/contexts/DataContext.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { createContext } from "react"; -import type { Container } from "@/.ldo/container.typings"; - -interface DataContextType { - contactsContainer: Container | undefined; - contacts: Array<{ "@id": string }>; - isContactsLoading: boolean; - containerOverlay: string; -} - -export const DataContext = createContext(undefined); -export type { DataContextType }; \ No newline at end of file diff --git a/src/hooks/useData.ts b/src/hooks/useData.ts deleted file mode 100644 index a4e14c0..0000000 --- a/src/hooks/useData.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { useContext } from "react"; -import { DataContext } from "@/contexts/DataContext"; - -export const useData = () => { - const context = useContext(DataContext); - if (!context) { - throw new Error("useData must be used within a DataProvider"); - } - return context; -}; \ No newline at end of file diff --git a/src/providers/DataProvider.tsx b/src/providers/DataProvider.tsx deleted file mode 100644 index 4599b83..0000000 --- a/src/providers/DataProvider.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import type React from "react"; -import type { ReactNode } from "react"; -import { useNextGraphAuth } from "@/lib/nextgraph"; -import { useResource, useSubject } from "@/lib/nextgraph"; -import { ContainerShapeType } from "@/.ldo/container.shapeTypes"; -import type { NextGraphAuth } from "@/types/nextgraph"; -import { DataContext, type DataContextType } from "@/contexts/DataContext"; - -interface DataProviderProps { - children: ReactNode; -} - -export const DataProvider: React.FC = ({ children }) => { - const nextGraphAuth = useNextGraphAuth() as NextGraphAuth; - const { session } = nextGraphAuth || {}; - const isAuthenticated = Boolean(session?.ng); - - const canSubscribe = - isAuthenticated && session?.privateStoreId && session?.ng; - - useResource(canSubscribe ? `did:ng:${session?.privateStoreId}` : undefined, { - subscribe: true, - }); - - const contactsContainer = useSubject( - ContainerShapeType, - canSubscribe && session?.privateStoreId - ? `did:ng:${session.privateStoreId.substring(0, 46)}` - : undefined, - ); - - const contacts = contactsContainer?.contains - ? Array.from(contactsContainer.contains) - : []; - const isContactsLoading = canSubscribe && !contactsContainer; - - const containerOverlay = session?.privateStoreId - ? session.privateStoreId.substring(46) - : ""; - - const value: DataContextType = { - contactsContainer, - contacts, - isContactsLoading, - containerOverlay, - }; - - return {children}; -};