mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 01:40:15 +01:00
fix: Ensure favorites are always an array and update references in FavoritesList
This commit is contained in:
parent
99b69c5b81
commit
83127a4ea5
2 changed files with 16 additions and 9 deletions
|
|
@ -22,8 +22,11 @@ import { logger } from '~/utils';
|
|||
/**
|
||||
* Cleans favorites array to only include canonical shapes (agentId or model+endpoint).
|
||||
*/
|
||||
const cleanFavorites = (favorites: Favorite[]): Favorite[] =>
|
||||
favorites.map((f) => {
|
||||
const cleanFavorites = (favorites: Favorite[]): Favorite[] => {
|
||||
if (!Array.isArray(favorites)) {
|
||||
return [];
|
||||
}
|
||||
return favorites.map((f) => {
|
||||
if (f.agentId) {
|
||||
return { agentId: f.agentId };
|
||||
}
|
||||
|
|
@ -32,6 +35,7 @@ const cleanFavorites = (favorites: Favorite[]): Favorite[] =>
|
|||
}
|
||||
return f;
|
||||
});
|
||||
};
|
||||
|
||||
export default function useFavorites() {
|
||||
const localize = useLocalize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue