mirror of https://github.com/buster-so/buster.git
favorites update
This commit is contained in:
parent
92b31a2f87
commit
d542862e7b
|
@ -13,6 +13,7 @@ import {
|
||||||
import { checkIfUserIsAdmin } from './helpers';
|
import { checkIfUserIsAdmin } from './helpers';
|
||||||
import { useUserOrganization } from './useUserOrganization';
|
import { useUserOrganization } from './useUserOrganization';
|
||||||
import { useInviteUser } from './useInviteUser';
|
import { useInviteUser } from './useInviteUser';
|
||||||
|
import { useWhyDidYouUpdate } from 'ahooks';
|
||||||
|
|
||||||
export const useUserConfigProvider = ({ userInfo }: { userInfo: BusterUserResponse | null }) => {
|
export const useUserConfigProvider = ({ userInfo }: { userInfo: BusterUserResponse | null }) => {
|
||||||
const isAnonymousUser = useSupabaseContext((state) => state.isAnonymousUser);
|
const isAnonymousUser = useSupabaseContext((state) => state.isAnonymousUser);
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { useMemoizedFn } from 'ahooks';
|
import { useMemoizedFn } from 'ahooks';
|
||||||
import { useSocketQueryEmitOn, useSocketQueryMutation } from '@/api/buster_socket_query';
|
import { useSocketQueryEmitOn, useSocketQueryMutation } from '@/api/buster_socket_query';
|
||||||
import { queryKeys } from '@/api/query_keys';
|
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 = () => {
|
export const useFavoriteProvider = () => {
|
||||||
const { data: userFavorites, refetch: refreshFavoritesList } = useSocketQueryEmitOn({
|
const { data: userFavorites, refetch: refreshFavoritesList } = useSocketQueryEmitOn({
|
||||||
|
@ -42,7 +46,7 @@ export const useFavoriteProvider = () => {
|
||||||
return {
|
return {
|
||||||
bulkEditFavorites,
|
bulkEditFavorites,
|
||||||
refreshFavoritesList,
|
refreshFavoritesList,
|
||||||
userFavorites: userFavorites || [],
|
userFavorites: isEmpty(userFavorites) ? DEFAULT_FAVORITES : userFavorites,
|
||||||
addItemToFavorite,
|
addItemToFavorite,
|
||||||
removeItemFromFavorite
|
removeItemFromFavorite
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue