@@ -76,8 +76,11 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
76
76
. limit ( 300 )
77
77
. toArray ( ) ;
78
78
79
+ const userAssistants = settings ?. assistants ?. map ( ( assistantId ) => assistantId . toString ( ) ) ?? [ ] ;
80
+ const userAssistantsSet = new Set ( userAssistants ) ;
81
+
79
82
const assistantIds = [
80
- ...( settings ?. assistants ?. map ( ( assistantId ) => assistantId ) ?? [ ] ) ,
83
+ ...userAssistants . map ( ( el ) => new ObjectId ( el ) ) ,
81
84
...( conversations . map ( ( conv ) => conv . assistantId ) . filter ( ( el ) => ! ! el ) as ObjectId [ ] ) ,
82
85
] ;
83
86
@@ -147,7 +150,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
147
150
settings ?. shareConversationsWithModelAuthors ??
148
151
DEFAULT_SETTINGS . shareConversationsWithModelAuthors ,
149
152
customPrompts : settings ?. customPrompts ?? { } ,
150
- assistants : settings ?. assistants ?. map ( ( el ) => el . toString ( ) ) ?? [ ] ,
153
+ assistants : userAssistants ,
151
154
} ,
152
155
models : models . map ( ( model ) => ( {
153
156
id : model . id ,
@@ -166,12 +169,15 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
166
169
unlisted : model . unlisted ,
167
170
} ) ) ,
168
171
oldModels,
169
- assistants : assistants . map ( ( el ) => ( {
170
- ...el ,
171
- _id : el . _id . toString ( ) ,
172
- createdById : undefined ,
173
- createdByMe : el . createdById . toString ( ) === ( locals . user ?. _id ?? locals . sessionId ) . toString ( ) ,
174
- } ) ) ,
172
+ assistants : assistants
173
+ . filter ( ( el ) => userAssistantsSet . has ( el . _id . toString ( ) ) )
174
+ . map ( ( el ) => ( {
175
+ ...el ,
176
+ _id : el . _id . toString ( ) ,
177
+ createdById : undefined ,
178
+ createdByMe :
179
+ el . createdById . toString ( ) === ( locals . user ?. _id ?? locals . sessionId ) . toString ( ) ,
180
+ } ) ) ,
175
181
user : locals . user && {
176
182
id : locals . user . _id . toString ( ) ,
177
183
username : locals . user . username ,
0 commit comments