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