@@ -147,18 +147,21 @@ export async function mainMenu(user: User) {
147147 return acc ;
148148 } , { } ) ;
149149
150- const preferenceItems = await MetaObject . Collections [ 'Preference' ]
151- . find < {
152- _id : string ;
153- code : string ;
154- type : string ;
155- name : string ;
156- document : string ;
157- target : string ;
158- view ?: string ;
159- value : string ;
160- } > ( { '_user._id' : user . _id , type : { $in : [ 'list' , 'pivot' ] } , target : 'Display' } )
161- . toArray ( ) ;
150+ const preferenceCollection = MetaObject . Collections [ 'Preference' ] ;
151+ const preferenceItems = preferenceCollection
152+ ? await preferenceCollection
153+ . find < {
154+ _id : string ;
155+ code : string ;
156+ type : string ;
157+ name : string ;
158+ document : string ;
159+ target : string ;
160+ view ?: string ;
161+ value : string ;
162+ } > ( { '_user._id' : user . _id , type : { $in : [ 'list' , 'pivot' ] } , target : 'Display' } )
163+ . toArray ( )
164+ : [ ] ;
162165
163166 preferenceItems . forEach ( ( item , index ) => {
164167 const document = getDocumentName ( { type : item . type , name : item . name , document : item . document } ) ;
@@ -277,10 +280,7 @@ export async function menuByDocumentSorter(user: User, targetSorter: number): Pr
277280 document : { $in : documentNames } ,
278281 } ) . toArray ( ) ;
279282
280- const menuItens = sortBy (
281- [ ...documents , ...groups , ...listsAndPivots ] ,
282- [ 'menuSorter' , 'name' ] ,
283- ) as MenuItemsMeta [ ] ;
283+ const menuItens = sortBy ( [ ...documents , ...groups , ...listsAndPivots ] , [ 'menuSorter' , 'name' ] ) as MenuItemsMeta [ ] ;
284284
285285 const accessAllowed = ( type : string , name : string ) => {
286286 if ( type === 'group' ) return true ;
@@ -295,17 +295,7 @@ export async function menuByDocumentSorter(user: User, targetSorter: number): Pr
295295 return null ;
296296 } ;
297297
298- const getItemPath = ( {
299- type,
300- name,
301- group : itemGroup ,
302- document : itemDocument ,
303- } : {
304- type : string ;
305- name : string ;
306- group ?: string ;
307- document ?: string ;
308- } ) => {
298+ const getItemPath = ( { type, name, group : itemGroup , document : itemDocument } : { type : string ; name : string ; group ?: string ; document ?: string } ) => {
309299 const document = getDocumentName ( { type, name, document : itemDocument } ) ;
310300 if ( document == null ) return null ;
311301 const itemPath : Array < string > = [ ] ;
0 commit comments