favorites update

This commit is contained in:
Nate Kelley 2025-02-18 14:42:49 -07:00
parent 92b31a2f87
commit d542862e7b
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import {
import { checkIfUserIsAdmin } from './helpers';
import { useUserOrganization } from './useUserOrganization';
import { useInviteUser } from './useInviteUser';
import { useWhyDidYouUpdate } from 'ahooks';
export const useUserConfigProvider = ({ userInfo }: { userInfo: BusterUserResponse | null }) => {
const isAnonymousUser = useSupabaseContext((state) => state.isAnonymousUser);

View File

@ -1,6 +1,10 @@
import { useMemoizedFn } from 'ahooks';
import { useSocketQueryEmitOn, useSocketQueryMutation } from '@/api/buster_socket_query';
import { queryKeys } from '@/api/query_keys';
import type { BusterUserFavorite } from '@/api/asset_interfaces';
import isEmpty from 'lodash/isEmpty';
const DEFAULT_FAVORITES: BusterUserFavorite[] = [];
export const useFavoriteProvider = () => {
const { data: userFavorites, refetch: refreshFavoritesList } = useSocketQueryEmitOn({
@ -42,7 +46,7 @@ export const useFavoriteProvider = () => {
return {
bulkEditFavorites,
refreshFavoritesList,
userFavorites: userFavorites || [],
userFavorites: isEmpty(userFavorites) ? DEFAULT_FAVORITES : userFavorites,
addItemToFavorite,
removeItemFromFavorite
};