mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
fix(brains): recursion
This commit is contained in:
parent
ed28d65303
commit
7143e04aef
@ -1,9 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { setEmptyStringsUndefined } from "@/lib/helpers/setEmptyStringsUndefined";
|
||||
import { createContext, useEffect, useState } from "react";
|
||||
import { BrainScope, ScopeContext } from "./types";
|
||||
import { createContext } from "react";
|
||||
import _useBrainScopeState from "./hooks/_useBrainScopeState";
|
||||
import { ScopeContext } from "./types";
|
||||
|
||||
export const BrainScopeContext = createContext<ScopeContext | undefined>(
|
||||
undefined
|
||||
|
@ -1,6 +1,6 @@
|
||||
import useDocuments from "@/app/explore/hooks/useDocuments";
|
||||
import { Document } from "@/app/explore/types";
|
||||
import generateUUID from "@/lib/helpers/generateUUID";
|
||||
import { useAxios } from "@/lib/useAxios";
|
||||
import { UUID } from "crypto";
|
||||
import { useEffect, useState } from "react";
|
||||
import { BrainScope } from "../types";
|
||||
@ -11,7 +11,8 @@ export default function _useBrainScopeState() {
|
||||
// currentBrain will change if we change currentBrainIndex or allBrains
|
||||
const currentBrain = allBrains.find((brain) => brain.id === currentBrainId);
|
||||
|
||||
const { documents: allDocuments } = useDocuments();
|
||||
const [allDocuments, setAllDocuments] = useState<Document[]>([]);
|
||||
const { axiosInstance } = useAxios();
|
||||
|
||||
const createBrain = (name: string, id?: UUID) => {
|
||||
let _id = generateUUID();
|
||||
@ -57,12 +58,21 @@ export default function _useBrainScopeState() {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// setCurrentBrain(getBrainFromLocalStorage());
|
||||
// TODO: redo logic to fetch brains from db or localstorage
|
||||
setAllBrains([
|
||||
{ name: "Super Brain", id: "super-duper-brain", documents: allDocuments },
|
||||
]);
|
||||
}, [allDocuments]);
|
||||
(async () => {
|
||||
const response = await axiosInstance.get<{ documents: Document[] }>(
|
||||
"/explore"
|
||||
);
|
||||
setAllDocuments(response.data.documents);
|
||||
// TODO: redo logic to fetch brains from db or localstorage
|
||||
setAllBrains([
|
||||
{
|
||||
name: "Super Brain",
|
||||
id: "super-duper-brain",
|
||||
documents: response.data.documents,
|
||||
},
|
||||
]);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
currentBrain,
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { createMiddlewareSupabaseClient } from '@supabase/auth-helpers-nextjs'
|
||||
import { NextResponse } from 'next/server'
|
||||
import { createMiddlewareSupabaseClient } from "@supabase/auth-helpers-nextjs";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import type { NextRequest } from 'next/server'
|
||||
import type { NextRequest } from "next/server";
|
||||
// import type { Database } from '@/lib/database.types'
|
||||
|
||||
export async function middleware(req: NextRequest) {
|
||||
const res = NextResponse.next()
|
||||
const supabase = createMiddlewareSupabaseClient({ req, res })
|
||||
await supabase.auth.getSession()
|
||||
return res
|
||||
}
|
||||
const res = NextResponse.next();
|
||||
const supabase = createMiddlewareSupabaseClient({ req, res });
|
||||
await supabase.auth.getSession();
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user