diff --git a/app/src/context/functions.tsx b/app/src/context/functions.tsx index 30d17cffb..77fdb08e5 100644 --- a/app/src/context/functions.tsx +++ b/app/src/context/functions.tsx @@ -90,11 +90,9 @@ const getProjects = async (url: string, token: string) => { headers: { Authorization: `Bearer ${token}`, }, - }).catch(() => { - return null; }); - if (response === null || (response && !response.ok)) { + if (!response.ok) { console.error(`Error fetching projects from ${url}`); return [] as ProjectObject[]; } diff --git a/app/src/context/projects-context.tsx b/app/src/context/projects-context.tsx index 6e6fc95d5..a6826f777 100644 --- a/app/src/context/projects-context.tsx +++ b/app/src/context/projects-context.tsx @@ -7,8 +7,6 @@ import { import {activate_project} from '../sync/process-initialization'; import {ProjectExtended} from '../types/project'; import {getLocalActiveMap, getProjectMap, getRemoteProjects} from './functions'; -import {getAvailableProjectsFromListing} from '../sync/projects'; -import {getAllListingIDs, getListing} from '../sync/state'; export const ProjectsContext = createContext<{ projects: ProjectExtended[]; @@ -32,7 +30,6 @@ export const ProjectsContext = createContext<{ export function ProjectsProvider({children}: {children: ReactNode}) { const [projects, setProjects] = useState([]); - console.debug('projectsProvider', projects); useEffect(() => { initProjects(); }, []); @@ -55,36 +52,6 @@ export function ProjectsProvider({children}: {children: ReactNode}) { const localActiveMap = await getLocalActiveMap(); - // if we're offline, remote projects is empty so just - // return the local ones we know already - - if (remoteProjects.length === 0) { - const allStoredProjects: ProjectExtended[] = []; - getAllListingIDs().forEach(async (listing_id: string) => { - const storedProjects = - await getAvailableProjectsFromListing(listing_id); - console.debug('storedProjects', storedProjects); - // storedProjects is ProjectInformation[] and we need ProjectExtended[] - const listing = await getListing(listing_id); - allStoredProjects.concat( - storedProjects.map(project => { - return { - ...project, - _id: project.project_id, - conductor_url: listing.listing.conductor_url, - listing: listing_id, - activated: localActiveMap.has(project.project_id), - sync: localProjectsMap.get(project.project_id)?.sync ?? false, - // do we also need the two database connections here??? - }; - }) - ); - }); - console.debug('allStoredProjects', allStoredProjects); - setProjects(allStoredProjects); - return; - } - for (const remoteProject of remoteProjects) { const activated = localProjectsMap.get(remoteProject._id)?.activated ?? @@ -103,7 +70,6 @@ export function ProjectsProvider({children}: {children: ReactNode}) { }); } - console.debug('setting projects', [...newProjectsMap.values()]); setProjects([...newProjectsMap.values()]); }; @@ -121,8 +87,6 @@ export function ProjectsProvider({children}: {children: ReactNode}) { const projectsMap = getProjectMap(projects); const newProjectsMap = getProjectMap(projects); - if (remoteProjects.length === 0) return; - // update project list, preserve activated and sync states from existing list for (const remoteProject of remoteProjects) { newProjectsMap.set(remoteProject._id, { diff --git a/app/src/dbs/projects-db.tsx b/app/src/dbs/projects-db.tsx index dffda1846..58bf5b12c 100644 --- a/app/src/dbs/projects-db.tsx +++ b/app/src/dbs/projects-db.tsx @@ -35,7 +35,6 @@ export const updateProjectsDB = async (projects: ProjectExtended[]) => * @returns A promise that resolves when the project is activated. */ export const activateProjectDB = async (_id: string) => { - console.debug('activateProjectDB', await db.info()); const doc = await db.get(_id); await db.put({ @@ -74,7 +73,6 @@ export const setSyncProjectDB = async (_id: string, sync: boolean) => { * @returns An array of local projects. */ export const getProjectsDB = async () => { - console.debug('getProjectsDB', await db.info()); const {rows} = await db.allDocs({include_docs: true}); return rows.map(row => row?.doc?.project).filter(x => x !== undefined); diff --git a/app/src/gui/components/workspace/notebooks.tsx b/app/src/gui/components/workspace/notebooks.tsx index 101b6f0a2..36a550630 100644 --- a/app/src/gui/components/workspace/notebooks.tsx +++ b/app/src/gui/components/workspace/notebooks.tsx @@ -69,8 +69,6 @@ export default function NoteBooks() { const activatedProjects = projects.filter(({activated}) => activated); - console.debug('PPPPP', projects, activatedProjects); - const [tabID, setTabID] = useState('1'); const history = useNavigate();