The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/client/sidebar/hooks/useQueryOptions.js

22 lines
643 B

import { useMemo } from 'react';
import { useSetting } from '../../contexts/SettingsContext';
import { useUserPreference } from '../../contexts/UserContext';
export const useQueryOptions = () => {
const sortBy = useUserPreference('sidebarSortby');
const showRealName = useSetting('UI_Use_Real_Name');
return useMemo(
() => ({
sort: {
...(sortBy === 'activity' && { lm: -1 }),
...(sortBy !== 'activity' && {
...(showRealName && { lowerCaseFName: /descending/.test(sortBy) ? -1 : 1 }),
...(!showRealName && { lowerCaseName: /descending/.test(sortBy) ? -1 : 1 }),
}),
},
}),
[sortBy, showRealName],
);
};