mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-27 02:33:48 +02:00
refactor store
This commit is contained in:
@@ -11,17 +11,18 @@ vi.mock('../../service/request', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../../stores', () => ({
|
||||
useFavoriteStore: () => ({
|
||||
handleFavoriteAdd: (...args) => mockHandleFavoriteAdd(...args),
|
||||
handleFavoriteDelete: (...args) => mockHandleFavoriteDelete(...args),
|
||||
handleFavoriteGroupClear: (...args) =>
|
||||
mockHandleFavoriteGroupClear(...args)
|
||||
}),
|
||||
useUserStore: () => ({
|
||||
currentUser: { id: 'usr_me' }
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../coordinators/favoriteCoordinator', () => ({
|
||||
handleFavoriteAdd: (...args) => mockHandleFavoriteAdd(...args),
|
||||
handleFavoriteDelete: (...args) => mockHandleFavoriteDelete(...args),
|
||||
handleFavoriteGroupClear: (...args) =>
|
||||
mockHandleFavoriteGroupClear(...args)
|
||||
}));
|
||||
|
||||
vi.mock('../../queries', () => ({
|
||||
queryClient: {
|
||||
invalidateQueries: (...args) => mockInvalidateQueries(...args)
|
||||
|
||||
@@ -6,6 +6,9 @@ const mockGetWorlds = vi.fn();
|
||||
const mockGetGroupCalendar = vi.fn();
|
||||
|
||||
vi.mock('../../queries', () => ({
|
||||
queryClient: {
|
||||
invalidateQueries: vi.fn().mockResolvedValue(undefined)
|
||||
},
|
||||
entityQueryPolicies: {
|
||||
user: { staleTime: 20000, gcTime: 90000, retry: 1, refetchOnWindowFocus: false },
|
||||
worldCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { useFavoriteStore, useUserStore } from '../stores';
|
||||
import {
|
||||
handleFavoriteAdd,
|
||||
handleFavoriteDelete,
|
||||
handleFavoriteGroupClear
|
||||
} from '../coordinators/favoriteCoordinator';
|
||||
import { queryClient } from '../queries';
|
||||
import { request } from '../service/request';
|
||||
|
||||
@@ -63,7 +68,7 @@ const favoriteReq = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
useFavoriteStore().handleFavoriteAdd(args);
|
||||
handleFavoriteAdd(args);
|
||||
refetchActiveFavoriteQueries();
|
||||
return args;
|
||||
});
|
||||
@@ -81,7 +86,7 @@ const favoriteReq = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
useFavoriteStore().handleFavoriteDelete(params.objectId);
|
||||
handleFavoriteDelete(params.objectId);
|
||||
refetchActiveFavoriteQueries();
|
||||
return args;
|
||||
});
|
||||
@@ -145,7 +150,7 @@ const favoriteReq = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
useFavoriteStore().handleFavoriteGroupClear(args);
|
||||
handleFavoriteGroupClear(args);
|
||||
refetchActiveFavoriteQueries();
|
||||
return args;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user