Skip to content

Commit a1495d8

Browse files
authored
[masterbots.ai] fix: show appropriate bot cards in the user thread list (#368)
* update * fix: update * update * update * fix: filter category & chatbot by userId on profile page * fix: hide empty chatbots
1 parent f3516c2 commit a1495d8

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

apps/masterbots.ai/lib/hooks/use-sidebar.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,18 @@ export function SidebarProvider({ children }: SidebarProviderProps) {
7373
loading,
7474
error,
7575
} = useAsync(async () => {
76-
let categories = []
77-
let userId = null
78-
if (slug) {
79-
const { user, error } = await getUserBySlug({
80-
slug: slug as string,
81-
isSameUser: false,
82-
})
83-
84-
if (error) {
85-
throw new Error(error)
86-
}
8776

88-
userId = user?.userId
77+
let userId = null
78+
if(slug){
79+
const { user, error } = await getUserBySlug({
80+
slug: slug as string,
81+
isSameUser: false
82+
});
83+
if(error) throw error
84+
userId = user ? user?.userId : null
8985
}
90-
91-
categories = await getCategories()
92-
86+
87+
const categories = await getCategories(userId)
9388
const categoriesObj = {
9489
categoriesChatbots: categories || [],
9590
categoriesId: categories.map((category) => category.categoryId),

apps/masterbots.ai/services/hasura/hasura.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export async function getCategories(userId?: string) {
5959
},
6060
},
6161
__scalar: true,
62+
__args: userId ? {
63+
where: {
64+
chatbot: {
65+
threads: {
66+
userId: { _eq: userId }
67+
}
68+
}
69+
}
70+
} : {},
6271
},
6372
__scalar: true,
6473
__args: {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
],
2929
"packageManager": "bun@1.1.31",
3030
"dependencies": {
31-
"axios": "^1.7.7",
32-
"remark-gfm": "^4.0.0"
31+
"axios": "^1.7.7"
3332
}
3433
}

0 commit comments

Comments
 (0)