mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-03 21:36:06 +02:00
merge group api request
This commit is contained in:
@@ -23,7 +23,7 @@ vi.mock('../../stores', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../query', () => ({
|
||||
vi.mock('../../queries', () => ({
|
||||
entityQueryPolicies: {
|
||||
user: { staleTime: 20000, gcTime: 90000, retry: 1, refetchOnWindowFocus: false },
|
||||
avatar: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
|
||||
@@ -23,7 +23,7 @@ vi.mock('../../stores', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../query', () => ({
|
||||
vi.mock('../../queries', () => ({
|
||||
entityQueryPolicies: {
|
||||
favoriteCollection: {
|
||||
staleTime: 60000,
|
||||
|
||||
@@ -15,7 +15,7 @@ vi.mock('../../stores/user', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../query', () => ({
|
||||
vi.mock('../../queries', () => ({
|
||||
entityQueryPolicies: {
|
||||
friendList: {
|
||||
staleTime: 20000,
|
||||
|
||||
@@ -18,7 +18,7 @@ vi.mock('../../stores', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../query', () => ({
|
||||
vi.mock('../../queries', () => ({
|
||||
entityQueryPolicies: {
|
||||
group: {
|
||||
staleTime: 60000,
|
||||
|
||||
@@ -15,7 +15,7 @@ vi.mock('../../stores', () => ({
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('../../query', () => ({
|
||||
vi.mock('../../queries', () => ({
|
||||
entityQueryPolicies: {
|
||||
galleryCollection: {
|
||||
staleTime: 60000,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
patchAndRefetchActiveQuery,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
const avatarReq = {
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function getCurrentUserId() {
|
||||
return useUserStore().currentUser.id;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function refetchActiveFriendListQueries() {
|
||||
queryClient
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function getCurrentUserId() {
|
||||
return useUserStore().currentUser.id;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
patchAndRefetchActiveQuery,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
const instanceReq = {
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function refetchActiveInventoryQueries() {
|
||||
queryClient
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function getCurrentUserId() {
|
||||
return useUserStore().currentUser.id;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
patchAndRefetchActiveQuery,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function refetchActiveGalleryQueries() {
|
||||
queryClient
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
queryClient,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
function getCurrentUserId() {
|
||||
return useUserStore().currentUser.id;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
fetchWithEntityPolicy,
|
||||
patchAndRefetchActiveQuery,
|
||||
queryKeys
|
||||
} from '../query';
|
||||
} from '../queries';
|
||||
|
||||
const worldReq = {
|
||||
/**
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import {
|
||||
initSentry
|
||||
} from './plugin';
|
||||
import { initPiniaPlugins, pinia } from './stores';
|
||||
import { queryClient } from './query';
|
||||
import { queryClient } from './queries';
|
||||
|
||||
import App from './App.vue';
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ function getComparableEntity(data) {
|
||||
if (data.ref && typeof data.ref === 'object') {
|
||||
return data.ref;
|
||||
}
|
||||
if (data.json && typeof data.json === 'object' && !Array.isArray(data.json)) {
|
||||
if (
|
||||
data.json &&
|
||||
typeof data.json === 'object' &&
|
||||
!Array.isArray(data.json)
|
||||
) {
|
||||
return data.json;
|
||||
}
|
||||
return data;
|
||||
@@ -137,8 +141,10 @@ export async function patchAndRefetchActiveQuery({ queryKey, nextData }) {
|
||||
*/
|
||||
export function patchUserFromEvent(ref) {
|
||||
if (!ref?.id) return;
|
||||
const queryKey = queryKeys.user(ref.id);
|
||||
if (!queryClient.getQueryData(queryKey)) return;
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.user(ref.id),
|
||||
queryKey,
|
||||
nextData: {
|
||||
cache: false,
|
||||
json: ref,
|
||||
@@ -153,8 +159,10 @@ export function patchUserFromEvent(ref) {
|
||||
*/
|
||||
export function patchAvatarFromEvent(ref) {
|
||||
if (!ref?.id) return;
|
||||
const queryKey = queryKeys.avatar(ref.id);
|
||||
if (!queryClient.getQueryData(queryKey)) return;
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.avatar(ref.id),
|
||||
queryKey,
|
||||
nextData: {
|
||||
cache: false,
|
||||
json: ref,
|
||||
@@ -169,8 +177,10 @@ export function patchAvatarFromEvent(ref) {
|
||||
*/
|
||||
export function patchWorldFromEvent(ref) {
|
||||
if (!ref?.id) return;
|
||||
const queryKey = queryKeys.world(ref.id);
|
||||
if (!queryClient.getQueryData(queryKey)) return;
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.world(ref.id),
|
||||
queryKey,
|
||||
nextData: {
|
||||
cache: false,
|
||||
json: ref,
|
||||
@@ -193,15 +203,21 @@ export function patchGroupFromEvent(ref) {
|
||||
ref
|
||||
};
|
||||
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.group(ref.id, false),
|
||||
nextData
|
||||
});
|
||||
const keyFalse = queryKeys.group(ref.id, false);
|
||||
if (queryClient.getQueryData(keyFalse)) {
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: keyFalse,
|
||||
nextData
|
||||
});
|
||||
}
|
||||
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.group(ref.id, true),
|
||||
nextData
|
||||
});
|
||||
const keyTrue = queryKeys.group(ref.id, true);
|
||||
if (queryClient.getQueryData(keyTrue)) {
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: keyTrue,
|
||||
nextData
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,8 +229,11 @@ export function patchInstanceFromEvent(ref) {
|
||||
const [worldId, instanceId] = String(ref.id).split(':');
|
||||
if (!worldId || !instanceId) return;
|
||||
|
||||
const queryKey = queryKeys.instance(worldId, instanceId);
|
||||
if (!queryClient.getQueryData(queryKey)) return;
|
||||
|
||||
patchQueryDataWithRecency({
|
||||
queryKey: queryKeys.instance(worldId, instanceId),
|
||||
queryKey,
|
||||
nextData: {
|
||||
cache: false,
|
||||
json: ref,
|
||||
+1
-1
@@ -12,7 +12,7 @@ import { createAuthAutoLoginCoordinator } from './coordinators/authAutoLoginCoor
|
||||
import { createAuthCoordinator } from './coordinators/authCoordinator';
|
||||
import { database } from '../service/database';
|
||||
import { escapeTag } from '../shared/utils';
|
||||
import { queryClient } from '../query';
|
||||
import { queryClient } from '../queries';
|
||||
import { request } from '../service/request';
|
||||
import { useAdvancedSettingsStore } from './settings/advanced';
|
||||
import { useGeneralSettingsStore } from './settings/general';
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
import { avatarRequest, miscRequest } from '../api';
|
||||
import { AppDebug } from '../service/appConfig';
|
||||
import { database } from '../service/database';
|
||||
import { patchAvatarFromEvent } from '../query';
|
||||
import { patchAvatarFromEvent } from '../queries';
|
||||
import { processBulk } from '../service/request';
|
||||
import { useAdvancedSettingsStore } from './settings/advanced';
|
||||
import { useAvatarProviderStore } from './avatarProvider';
|
||||
|
||||
+17
-9
@@ -18,7 +18,7 @@ import {
|
||||
} from '../api';
|
||||
import { database } from '../service/database';
|
||||
import { groupDialogFilterOptions } from '../shared/constants/';
|
||||
import { patchGroupFromEvent } from '../query';
|
||||
import { patchGroupFromEvent } from '../queries';
|
||||
import { useGameStore } from './game';
|
||||
import { useInstanceStore } from './instance';
|
||||
import { useModalStore } from './modal';
|
||||
@@ -170,7 +170,7 @@ export const useGroupStore = defineStore('Group', () => {
|
||||
D.calendar = [];
|
||||
const loadGroupRequest = groupRequest.getGroup({
|
||||
groupId,
|
||||
includeRoles: false
|
||||
includeRoles: true
|
||||
});
|
||||
|
||||
loadGroupRequest
|
||||
@@ -208,7 +208,7 @@ export const useGroupStore = defineStore('Group', () => {
|
||||
}
|
||||
});
|
||||
instanceStore.applyGroupDialogInstances();
|
||||
getGroupDialogGroup(groupId);
|
||||
getGroupDialogGroup(groupId, ref);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -457,17 +457,25 @@ export const useGroupStore = defineStore('Group', () => {
|
||||
/**
|
||||
*
|
||||
* @param groupId
|
||||
* @param {object} [existingRef]
|
||||
* @returns { Promise<object> }
|
||||
*/
|
||||
function getGroupDialogGroup(groupId) {
|
||||
function getGroupDialogGroup(groupId, existingRef) {
|
||||
const D = groupDialog.value;
|
||||
D.isGetGroupDialogGroupLoading = false;
|
||||
return groupRequest
|
||||
.getCachedGroup({ groupId, includeRoles: true })
|
||||
|
||||
const refPromise = existingRef
|
||||
? Promise.resolve({ ref: existingRef })
|
||||
: groupRequest
|
||||
.getCachedGroup({ groupId, includeRoles: true })
|
||||
.then((args) => ({ ref: applyGroup(args.json), args }));
|
||||
|
||||
return refPromise
|
||||
.catch((err) => {
|
||||
throw err;
|
||||
})
|
||||
.then((args) => {
|
||||
const ref = applyGroup(args.json);
|
||||
.then((result) => {
|
||||
const ref = result.ref;
|
||||
if (D.id === ref.id) {
|
||||
D.loading = false;
|
||||
D.ref = ref;
|
||||
@@ -537,7 +545,7 @@ export const useGroupStore = defineStore('Group', () => {
|
||||
});
|
||||
}
|
||||
nextTick(() => (D.isGetGroupDialogGroupLoading = false));
|
||||
return args;
|
||||
return result.args || result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
instanceContentSettings
|
||||
} from '../shared/constants';
|
||||
import { database } from '../service/database';
|
||||
import { patchInstanceFromEvent } from '../query';
|
||||
import { patchInstanceFromEvent } from '../queries';
|
||||
import { resolveRef } from '../shared/utils/resolveRef';
|
||||
import { useAppearanceSettingsStore } from './settings/appearance';
|
||||
import { useFriendStore } from './friend';
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import { AppDebug } from '../service/appConfig';
|
||||
import { createUserEventCoordinator } from './coordinators/userEventCoordinator';
|
||||
import { createUserSessionCoordinator } from './coordinators/userSessionCoordinator';
|
||||
import { database } from '../service/database';
|
||||
import { patchUserFromEvent } from '../query';
|
||||
import { patchUserFromEvent } from '../queries';
|
||||
import { useAppearanceSettingsStore } from './settings/appearance';
|
||||
import { useAuthStore } from './auth';
|
||||
import { useAvatarStore } from './avatar';
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import {
|
||||
} from '../shared/utils';
|
||||
import { instanceRequest, miscRequest, worldRequest } from '../api';
|
||||
import { database } from '../service/database';
|
||||
import { patchWorldFromEvent } from '../query';
|
||||
import { patchWorldFromEvent } from '../queries';
|
||||
import { processBulk } from '../service/request';
|
||||
import { useFavoriteStore } from './favorite';
|
||||
import { useInstanceStore } from './instance';
|
||||
|
||||
Reference in New Issue
Block a user