Skip to content

Commit 6e9a67f

Browse files
committed
Removed required user in text search
1 parent 190a540 commit 6e9a67f

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

examples/example_pro/src/FirestoreApp/text_search.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export const pineconeSearchControllerBuilder = buildPineconeSearchController({
5353
searchString,
5454
currentUser
5555
}) => {
56+
if(!currentUser){
57+
throw new Error("User not authenticated");
58+
}
5659
if (path === "products")
5760
return performPineconeTextSearch({
5861
firebaseToken: await currentUser.getIdToken(),

examples/example_pro/src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from "react-dom/client"
33
import "./index.css"
44
import { BrowserRouter } from "react-router-dom"
55
import { App } from "./FirestoreApp/App";
6+
import GraphQLApp from "./GraphQLApp/GraphQLApp";
67
import MongoDBApp from "./MongoDBApp/MongoDBApp";
78
import SupabaseApp from "./SupabaseApp/SupabaseApp";
89

packages/firebase_firecms/src/hooks/useFirestoreDelegate.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,11 @@ export function useFirestoreDelegate({
217217

218218
const auth = getAuth(firebaseApp);
219219
const currentUser = auth.currentUser;
220-
if (!currentUser) throw Error("No current user");
221220

222221
const search = textSearchController.search({
223222
path,
224223
searchString,
225-
currentUser,
224+
currentUser: currentUser ?? undefined,
226225
databaseId
227226
});
228227

@@ -772,7 +771,7 @@ function buildTextSearchControllerWithLocalSearch({
772771
search: async (props: {
773772
searchString: string,
774773
path: string,
775-
currentUser: any,
774+
currentUser?: any,
776775
databaseId?: string
777776
}) => {
778777
const search = await textSearchController.search(props);

packages/firebase_firecms/src/types/text_search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type FirestoreTextSearchController = {
3434
search: (props: {
3535
searchString: string,
3636
path: string,
37-
currentUser: FirebaseUser,
37+
currentUser?: FirebaseUser,
3838
databaseId?: string
3939
}) => (Promise<readonly string[] | undefined>),
4040

packages/firebase_firecms/src/utils/pinecone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function buildPineconeSearchController({
5353
search: (props: {
5454
searchString: string,
5555
path: string,
56-
currentUser: FirebaseUser
56+
currentUser?: FirebaseUser
5757
}) => Promise<readonly string[] | undefined>,
5858
}): FirestoreTextSearchControllerBuilder {
5959
return (props): FirestoreTextSearchController => {

0 commit comments

Comments
 (0)