mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-24 01:03:50 +02:00
refactor queryRequest
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { queryClient } from '../queries';
|
||||
import { request } from '../service/request';
|
||||
import { useUserStore } from '../stores/user';
|
||||
import {
|
||||
entityQueryPolicies,
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../queries';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function refetchActiveFriendListQueries() {
|
||||
queryClient
|
||||
.invalidateQueries({
|
||||
@@ -44,22 +42,6 @@ const friendReq = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch friends from query cache if still fresh. Otherwise, calls API.
|
||||
* @param {{ n: number, offset: number, offline?: boolean }} params
|
||||
* @returns {Promise<{json: any, params: { n: number, offset: number, offline?: boolean }, cache?: boolean}>}
|
||||
*/
|
||||
getCachedFriends(params) {
|
||||
return fetchWithEntityPolicy({
|
||||
queryKey: queryKeys.friends(params),
|
||||
policy: entityQueryPolicies.friendList,
|
||||
queryFn: () => friendReq.getFriends(params)
|
||||
}).then(({ data, cache }) => ({
|
||||
...data,
|
||||
cache
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ userId: string }} params
|
||||
* @returns {Promise<{json: any, params: { userId: string }}>}
|
||||
@@ -96,6 +78,7 @@ const friendReq = {
|
||||
|
||||
/**
|
||||
* @param {{ userId: string }} params
|
||||
* @param customMsg
|
||||
* @returns {Promise<{json: any, params: { userId: string }}>}
|
||||
*/
|
||||
deleteFriend(params, customMsg) {
|
||||
|
||||
Reference in New Issue
Block a user