feat: clean up comments and improve code readability in favorites and agent components; bump @librechat/data-schemas to 0.0.24

This commit is contained in:
Marco Beretta 2025-11-23 23:44:35 +01:00
parent 4e4a132660
commit bfeae91a96
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
9 changed files with 55 additions and 52 deletions

View file

@ -37,10 +37,8 @@ const getFavoritesController = async (req, res) => {
let favorites = user.favorites || [];
// Ensure favorites is an array (migration/dev fix)
if (!Array.isArray(favorites)) {
favorites = [];
// Optionally update the DB to fix it permanently
await User.findByIdAndUpdate(userId, { $set: { favorites: [] } });
}

View file

@ -83,7 +83,7 @@ const AgentCard: React.FC<AgentCardProps> = ({ agent, onClick, className = '' })
</p>
</div>
{/* Owner info - moved to bottom right */}
{/* Owner info */}
{(() => {
const displayName = getContactDisplayName(agent);
if (displayName) {

View file

@ -141,24 +141,24 @@ const AgentDetail: React.FC<AgentDetailProps> = ({ agent, isOpen, onClose }) =>
return (
<OGDialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
<OGDialogContent ref={dialogRef} className="max-h-[90vh] w-11/12 max-w-lg overflow-y-auto">
{/* Agent avatar - top center */}
{/* Agent avatar */}
<div className="mt-6 flex justify-center">{renderAgentAvatar(agent, { size: 'xl' })}</div>
{/* Agent name - center aligned below image */}
{/* Agent name */}
<div className="mt-3 text-center">
<h2 className="text-2xl font-bold text-text-primary">
{agent?.name || localize('com_agents_loading')}
</h2>
</div>
{/* Contact info - center aligned below name */}
{/* Contact info */}
{agent?.support_contact && formatContact() && (
<div className="mt-1 text-center text-sm text-text-secondary">
{localize('com_agents_contact')}: {formatContact()}
</div>
)}
{/* Agent description - below contact */}
{/* Agent description */}
<div className="mt-4 whitespace-pre-wrap px-6 text-center text-base text-text-primary">
{agent?.description}
</div>

View file

@ -28,7 +28,6 @@ function ModelSelectorContent() {
searchValue,
searchResults,
selectedValues,
// Functions
setSearchValue,
setSelectedValues,

View file

@ -23,14 +23,15 @@ const DraggableFavoriteItem = ({
children,
}: DraggableFavoriteItemProps) => {
const ref = useRef<HTMLDivElement>(null);
const [{ handlerId }, drop] = useDrop({
const [{ handlerId }, drop] = useDrop<{ index: number; id: string }, unknown, { handlerId: any }>(
{
accept: 'favorite-item',
collect(monitor) {
return {
handlerId: monitor.getHandlerId(),
};
},
hover(item: { index: number; id: string }, monitor) {
hover(item, monitor) {
if (!ref.current) {
return;
}
@ -57,7 +58,8 @@ const DraggableFavoriteItem = ({
moveItem(dragIndex, hoverIndex);
item.index = hoverIndex;
},
});
},
);
const [{ isDragging }, drag] = useDrag({
type: 'favorite-item',

View file

@ -3,18 +3,23 @@ import { dataService } from 'librechat-data-provider';
import type { FavoritesState } from '~/store/favorites';
export const useGetFavoritesQuery = (config?: any) => {
return useQuery<FavoritesState>(['favorites'], () => dataService.getFavorites() as Promise<FavoritesState>, {
return useQuery<FavoritesState>(
['favorites'],
() => dataService.getFavorites() as Promise<FavoritesState>,
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
...config,
});
},
);
};
export const useUpdateFavoritesMutation = () => {
const queryClient = useQueryClient();
return useMutation(
(favorites: FavoritesState) => dataService.updateFavorites(favorites) as Promise<FavoritesState>,
(favorites: FavoritesState) =>
dataService.updateFavorites(favorites) as Promise<FavoritesState>,
{
onSuccess: (data) => {
queryClient.setQueryData(['favorites'], data);

2
package-lock.json generated
View file

@ -47913,7 +47913,7 @@
},
"packages/data-schemas": {
"name": "@librechat/data-schemas",
"version": "0.0.30",
"version": "0.0.31",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",

View file

@ -1,6 +1,6 @@
{
"name": "@librechat/data-schemas",
"version": "0.0.30",
"version": "0.0.31",
"description": "Mongoose schemas and models for LibreChat",
"type": "module",
"main": "dist/index.cjs",

View file

@ -39,7 +39,6 @@ export interface IUser extends Document {
models: Array<{
model: string;
endpoint: string;
label?: string;
}>;
};
createdAt?: Date;