mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
refactor query requests to use queryRequest module
This commit is contained in:
@@ -10,20 +10,35 @@ vi.mock('../../queries', () => ({
|
||||
user: { staleTime: 20000, gcTime: 90000, retry: 1, refetchOnWindowFocus: false },
|
||||
worldCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
groupCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
groupCalendarCollection: { staleTime: 120000, gcTime: 600000, retry: 1, refetchOnWindowFocus: false },
|
||||
groupFollowingCalendarCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
groupFeaturedCalendarCollection: { staleTime: 300000, gcTime: 900000, retry: 1, refetchOnWindowFocus: false },
|
||||
groupCalendarEvent: { staleTime: 120000, gcTime: 600000, retry: 1, refetchOnWindowFocus: false },
|
||||
avatar: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
avatarCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
avatarGallery: { staleTime: 30000, gcTime: 120000, retry: 1, refetchOnWindowFocus: false },
|
||||
world: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
group: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
friendList: { staleTime: 20000, gcTime: 90000, retry: 1, refetchOnWindowFocus: false },
|
||||
favoriteCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
galleryCollection: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
inventoryCollection: { staleTime: 20000, gcTime: 120000, retry: 1, refetchOnWindowFocus: false },
|
||||
inventoryObject: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false },
|
||||
fileAnalysis: { staleTime: 120000, gcTime: 600000, retry: 1, refetchOnWindowFocus: false },
|
||||
worldPersistData: { staleTime: 120000, gcTime: 600000, retry: 1, refetchOnWindowFocus: false },
|
||||
mutualCounts: { staleTime: 120000, gcTime: 600000, retry: 1, refetchOnWindowFocus: false },
|
||||
visits: { staleTime: 300000, gcTime: 900000, retry: 1, refetchOnWindowFocus: false },
|
||||
fileObject: { staleTime: 60000, gcTime: 300000, retry: 1, refetchOnWindowFocus: false }
|
||||
},
|
||||
fetchWithEntityPolicy: (...args) => mockFetchWithEntityPolicy(...args),
|
||||
queryKeys: {
|
||||
user: (userId) => ['user', userId],
|
||||
avatars: (params) => ['avatar', 'list', params],
|
||||
worldsByUser: (params) => ['worlds', 'user', params.userId, params],
|
||||
groupCalendar: (groupId) => ['group', groupId, 'calendar'],
|
||||
groupCalendars: (params) => ['group', 'calendar', params],
|
||||
followingGroupCalendars: (params) => ['group', 'calendar', 'following', params],
|
||||
featuredGroupCalendars: (params) => ['group', 'calendar', 'featured', params],
|
||||
avatar: (avatarId) => ['avatar', avatarId],
|
||||
world: (worldId) => ['world', worldId],
|
||||
group: (groupId, includeRoles) => ['group', groupId, Boolean(includeRoles)],
|
||||
@@ -32,6 +47,7 @@ vi.mock('../../queries', () => ({
|
||||
groupMembers: (params) => ['group', params.groupId, 'members', params],
|
||||
groupGallery: (params) => ['group', params.groupId, 'gallery', params.galleryId, params],
|
||||
groupCalendarEvent: (params) => ['group', params.groupId, 'calendarEvent', params.eventId],
|
||||
avatarGallery: (avatarId) => ['avatar', avatarId, 'gallery'],
|
||||
friends: (params) => ['friends', params],
|
||||
favoriteLimits: () => ['favorite', 'limits'],
|
||||
favorites: (params) => ['favorite', 'items', params],
|
||||
@@ -41,15 +57,22 @@ vi.mock('../../queries', () => ({
|
||||
galleryFiles: (params) => ['gallery', 'files', params],
|
||||
prints: (params) => ['gallery', 'prints', params],
|
||||
print: (printId) => ['gallery', 'print', printId],
|
||||
inventoryItem: (inventoryId) => ['inventory', 'item', inventoryId],
|
||||
userInventoryItem: (params) => ['inventory', 'item', params.userId, params.inventoryId],
|
||||
inventoryItems: (params) => ['inventory', 'items', params],
|
||||
inventoryTemplate: (inventoryTemplateId) => ['inventory', 'template', inventoryTemplateId],
|
||||
fileAnalysis: (params) => ['analysis', params.fileId, Number(params.version), String(params.variant || '')],
|
||||
worldPersistData: (worldId) => ['world', worldId, 'persistData'],
|
||||
mutualCounts: (userId) => ['user', userId, 'mutualCounts'],
|
||||
visits: () => ['visits'],
|
||||
file: (fileId) => ['file', fileId]
|
||||
}
|
||||
}));
|
||||
|
||||
vi.mock('../user', () => ({
|
||||
default: {
|
||||
getUser: (...args) => mockGetUser(...args)
|
||||
getUser: (...args) => mockGetUser(...args),
|
||||
getMutualCounts: vi.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -68,11 +91,16 @@ vi.mock('../group', () => ({
|
||||
getGroupMember: vi.fn(),
|
||||
getGroupMembers: vi.fn(),
|
||||
getGroupGallery: vi.fn(),
|
||||
getGroupCalendarEvent: vi.fn()
|
||||
getGroupCalendarEvent: vi.fn(),
|
||||
getGroupCalendars: vi.fn(),
|
||||
getFollowingGroupCalendars: vi.fn(),
|
||||
getFeaturedGroupCalendars: vi.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
vi.mock('../avatar', () => ({ default: { getAvatar: vi.fn() } }));
|
||||
vi.mock('../avatar', () => ({
|
||||
default: { getAvatar: vi.fn(), getAvatarGallery: vi.fn(), getAvatars: vi.fn() }
|
||||
}));
|
||||
vi.mock('../friend', () => ({ default: { getFriends: vi.fn() } }));
|
||||
vi.mock('../favorite', () => ({
|
||||
default: {
|
||||
@@ -88,9 +116,21 @@ vi.mock('../vrcPlusImage', () => ({
|
||||
default: { getPrints: vi.fn(), getPrint: vi.fn() }
|
||||
}));
|
||||
vi.mock('../inventory', () => ({
|
||||
default: { getUserInventoryItem: vi.fn(), getInventoryItems: vi.fn() }
|
||||
default: {
|
||||
getUserInventoryItem: vi.fn(),
|
||||
getInventoryItem: vi.fn(),
|
||||
getInventoryItems: vi.fn(),
|
||||
getInventoryTemplate: vi.fn()
|
||||
}
|
||||
}));
|
||||
vi.mock('../misc', () => ({
|
||||
default: {
|
||||
getFile: vi.fn(),
|
||||
getFileAnalysis: vi.fn(),
|
||||
getVisits: vi.fn(),
|
||||
hasWorldPersistData: vi.fn()
|
||||
}
|
||||
}));
|
||||
vi.mock('../misc', () => ({ default: { getFile: vi.fn() } }));
|
||||
|
||||
import queryRequest from '../queryRequest';
|
||||
|
||||
|
||||
@@ -67,11 +67,31 @@ const registry = Object.freeze({
|
||||
policy: entityQueryPolicies.groupCollection,
|
||||
queryFn: (params) => groupRequest.getGroupCalendar(params.groupId)
|
||||
},
|
||||
groupCalendars: {
|
||||
key: (params) => queryKeys.groupCalendars(params),
|
||||
policy: entityQueryPolicies.groupCalendarCollection,
|
||||
queryFn: (params) => groupRequest.getGroupCalendars(params)
|
||||
},
|
||||
followingGroupCalendars: {
|
||||
key: (params) => queryKeys.followingGroupCalendars(params),
|
||||
policy: entityQueryPolicies.groupFollowingCalendarCollection,
|
||||
queryFn: (params) => groupRequest.getFollowingGroupCalendars(params)
|
||||
},
|
||||
featuredGroupCalendars: {
|
||||
key: (params) => queryKeys.featuredGroupCalendars(params),
|
||||
policy: entityQueryPolicies.groupFeaturedCalendarCollection,
|
||||
queryFn: (params) => groupRequest.getFeaturedGroupCalendars(params)
|
||||
},
|
||||
groupCalendarEvent: {
|
||||
key: (params) => queryKeys.groupCalendarEvent(params),
|
||||
policy: entityQueryPolicies.groupCollection,
|
||||
policy: entityQueryPolicies.groupCalendarEvent,
|
||||
queryFn: (params) => groupRequest.getGroupCalendarEvent(params)
|
||||
},
|
||||
avatarGallery: {
|
||||
key: (params) => queryKeys.avatarGallery(params.avatarId),
|
||||
policy: entityQueryPolicies.avatarGallery,
|
||||
queryFn: (params) => avatarRequest.getAvatarGallery(params.avatarId)
|
||||
},
|
||||
friends: {
|
||||
key: (params) => queryKeys.friends(params),
|
||||
policy: entityQueryPolicies.friendList,
|
||||
@@ -122,11 +142,41 @@ const registry = Object.freeze({
|
||||
policy: entityQueryPolicies.inventoryCollection,
|
||||
queryFn: (params) => inventoryRequest.getUserInventoryItem(params)
|
||||
},
|
||||
inventoryItem: {
|
||||
key: (params) => queryKeys.inventoryItem(params.inventoryId),
|
||||
policy: entityQueryPolicies.inventoryObject,
|
||||
queryFn: (params) => inventoryRequest.getInventoryItem(params)
|
||||
},
|
||||
inventoryItems: {
|
||||
key: (params) => queryKeys.inventoryItems(params),
|
||||
policy: entityQueryPolicies.inventoryCollection,
|
||||
queryFn: (params) => inventoryRequest.getInventoryItems(params)
|
||||
},
|
||||
inventoryTemplate: {
|
||||
key: (params) => queryKeys.inventoryTemplate(params.inventoryTemplateId),
|
||||
policy: entityQueryPolicies.inventoryObject,
|
||||
queryFn: (params) => inventoryRequest.getInventoryTemplate(params)
|
||||
},
|
||||
fileAnalysis: {
|
||||
key: (params) => queryKeys.fileAnalysis(params),
|
||||
policy: entityQueryPolicies.fileAnalysis,
|
||||
queryFn: (params) => miscRequest.getFileAnalysis(params)
|
||||
},
|
||||
worldPersistData: {
|
||||
key: (params) => queryKeys.worldPersistData(params.worldId),
|
||||
policy: entityQueryPolicies.worldPersistData,
|
||||
queryFn: (params) => miscRequest.hasWorldPersistData(params)
|
||||
},
|
||||
mutualCounts: {
|
||||
key: (params) => queryKeys.mutualCounts(params.userId),
|
||||
policy: entityQueryPolicies.mutualCounts,
|
||||
queryFn: (params) => userRequest.getMutualCounts(params)
|
||||
},
|
||||
visits: {
|
||||
key: () => queryKeys.visits(),
|
||||
policy: entityQueryPolicies.visits,
|
||||
queryFn: () => miscRequest.getVisits()
|
||||
},
|
||||
file: {
|
||||
key: (params) => queryKeys.file(params.fileId),
|
||||
policy: entityQueryPolicies.fileObject,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { describe, expect, test } from 'vitest';
|
||||
|
||||
import {
|
||||
entityQueryPolicies,
|
||||
getEntityQueryPolicy,
|
||||
toQueryOptions
|
||||
} from '../policies';
|
||||
|
||||
@@ -42,6 +41,32 @@ describe('query policy configuration', () => {
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.groupCalendarCollection).toMatchObject({
|
||||
staleTime: 120000,
|
||||
gcTime: 600000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(
|
||||
entityQueryPolicies.groupFollowingCalendarCollection
|
||||
).toMatchObject({
|
||||
staleTime: 60000,
|
||||
gcTime: 300000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.groupFeaturedCalendarCollection).toMatchObject({
|
||||
staleTime: 300000,
|
||||
gcTime: 900000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.groupCalendarEvent).toMatchObject({
|
||||
staleTime: 120000,
|
||||
gcTime: 600000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
|
||||
expect(entityQueryPolicies.worldCollection).toMatchObject({
|
||||
staleTime: 60000,
|
||||
@@ -77,6 +102,42 @@ describe('query policy configuration', () => {
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.inventoryObject).toMatchObject({
|
||||
staleTime: 60000,
|
||||
gcTime: 300000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.avatarGallery).toMatchObject({
|
||||
staleTime: 30000,
|
||||
gcTime: 120000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.fileAnalysis).toMatchObject({
|
||||
staleTime: 120000,
|
||||
gcTime: 600000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.worldPersistData).toMatchObject({
|
||||
staleTime: 120000,
|
||||
gcTime: 600000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.mutualCounts).toMatchObject({
|
||||
staleTime: 120000,
|
||||
gcTime: 600000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
expect(entityQueryPolicies.visits).toMatchObject({
|
||||
staleTime: 300000,
|
||||
gcTime: 900000,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
});
|
||||
|
||||
expect(entityQueryPolicies.fileObject).toMatchObject({
|
||||
staleTime: 60000,
|
||||
@@ -86,34 +147,6 @@ describe('query policy configuration', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('exposes entity policy lookup', () => {
|
||||
expect(getEntityQueryPolicy('user')).toBe(entityQueryPolicies.user);
|
||||
expect(getEntityQueryPolicy('avatar')).toBe(entityQueryPolicies.avatar);
|
||||
expect(getEntityQueryPolicy('world')).toBe(entityQueryPolicies.world);
|
||||
expect(getEntityQueryPolicy('group')).toBe(entityQueryPolicies.group);
|
||||
expect(getEntityQueryPolicy('groupCollection')).toBe(
|
||||
entityQueryPolicies.groupCollection
|
||||
);
|
||||
expect(getEntityQueryPolicy('worldCollection')).toBe(
|
||||
entityQueryPolicies.worldCollection
|
||||
);
|
||||
expect(getEntityQueryPolicy('friendList')).toBe(
|
||||
entityQueryPolicies.friendList
|
||||
);
|
||||
expect(getEntityQueryPolicy('favoriteCollection')).toBe(
|
||||
entityQueryPolicies.favoriteCollection
|
||||
);
|
||||
expect(getEntityQueryPolicy('galleryCollection')).toBe(
|
||||
entityQueryPolicies.galleryCollection
|
||||
);
|
||||
expect(getEntityQueryPolicy('inventoryCollection')).toBe(
|
||||
entityQueryPolicies.inventoryCollection
|
||||
);
|
||||
expect(getEntityQueryPolicy('fileObject')).toBe(
|
||||
entityQueryPolicies.fileObject
|
||||
);
|
||||
});
|
||||
|
||||
test('normalizes policy values to query options', () => {
|
||||
const options = toQueryOptions(entityQueryPolicies.group);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ export { queryClient } from './client';
|
||||
export { queryKeys } from './keys';
|
||||
export {
|
||||
entityQueryPolicies,
|
||||
getEntityQueryPolicy,
|
||||
toQueryOptions
|
||||
} from './policies';
|
||||
export {
|
||||
|
||||
@@ -50,12 +50,42 @@ export const queryKeys = Object.freeze({
|
||||
}
|
||||
],
|
||||
groupCalendar: (groupId) => ['group', groupId, 'calendar'],
|
||||
groupCalendars: ({ n = 100, offset = 0, date = '' } = {}) => [
|
||||
'group',
|
||||
'calendar',
|
||||
{
|
||||
n: Number(n),
|
||||
offset: Number(offset),
|
||||
date: String(date || '')
|
||||
}
|
||||
],
|
||||
followingGroupCalendars: ({ n = 100, offset = 0, date = '' } = {}) => [
|
||||
'group',
|
||||
'calendar',
|
||||
'following',
|
||||
{
|
||||
n: Number(n),
|
||||
offset: Number(offset),
|
||||
date: String(date || '')
|
||||
}
|
||||
],
|
||||
featuredGroupCalendars: ({ n = 100, offset = 0, date = '' } = {}) => [
|
||||
'group',
|
||||
'calendar',
|
||||
'featured',
|
||||
{
|
||||
n: Number(n),
|
||||
offset: Number(offset),
|
||||
date: String(date || '')
|
||||
}
|
||||
],
|
||||
groupCalendarEvent: ({ groupId, eventId } = {}) => [
|
||||
'group',
|
||||
groupId,
|
||||
'calendarEvent',
|
||||
eventId
|
||||
],
|
||||
avatarGallery: (avatarId) => ['avatar', avatarId, 'gallery'],
|
||||
worldsByUser: ({
|
||||
userId,
|
||||
n = 50,
|
||||
@@ -176,5 +206,20 @@ export const queryKeys = Object.freeze({
|
||||
userId,
|
||||
inventoryId
|
||||
],
|
||||
inventoryItem: (inventoryId) => ['inventory', 'item', inventoryId],
|
||||
inventoryTemplate: (inventoryTemplateId) => [
|
||||
'inventory',
|
||||
'template',
|
||||
inventoryTemplateId
|
||||
],
|
||||
fileAnalysis: ({ fileId, version, variant } = {}) => [
|
||||
'analysis',
|
||||
fileId,
|
||||
Number(version),
|
||||
String(variant || '')
|
||||
],
|
||||
worldPersistData: (worldId) => ['world', worldId, 'persistData'],
|
||||
mutualCounts: (userId) => ['user', userId, 'mutualCounts'],
|
||||
visits: () => ['visits'],
|
||||
file: (fileId) => ['file', fileId]
|
||||
});
|
||||
|
||||
@@ -31,6 +31,30 @@ export const entityQueryPolicies = Object.freeze({
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
groupCalendarCollection: Object.freeze({
|
||||
staleTime: 120 * SECOND,
|
||||
gcTime: 600 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
groupFollowingCalendarCollection: Object.freeze({
|
||||
staleTime: 60 * SECOND,
|
||||
gcTime: 300 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
groupFeaturedCalendarCollection: Object.freeze({
|
||||
staleTime: 300 * SECOND,
|
||||
gcTime: 900 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
groupCalendarEvent: Object.freeze({
|
||||
staleTime: 120 * SECOND,
|
||||
gcTime: 600 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
worldCollection: Object.freeze({
|
||||
staleTime: 60 * SECOND,
|
||||
gcTime: 300 * SECOND,
|
||||
@@ -61,6 +85,42 @@ export const entityQueryPolicies = Object.freeze({
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
inventoryObject: Object.freeze({
|
||||
staleTime: 60 * SECOND,
|
||||
gcTime: 300 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
avatarGallery: Object.freeze({
|
||||
staleTime: 30 * SECOND,
|
||||
gcTime: 120 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
fileAnalysis: Object.freeze({
|
||||
staleTime: 120 * SECOND,
|
||||
gcTime: 600 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
worldPersistData: Object.freeze({
|
||||
staleTime: 120 * SECOND,
|
||||
gcTime: 600 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
mutualCounts: Object.freeze({
|
||||
staleTime: 120 * SECOND,
|
||||
gcTime: 600 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
visits: Object.freeze({
|
||||
staleTime: 300 * SECOND,
|
||||
gcTime: 900 * SECOND,
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false
|
||||
}),
|
||||
fileObject: Object.freeze({
|
||||
staleTime: 60 * SECOND,
|
||||
gcTime: 300 * SECOND,
|
||||
@@ -69,14 +129,6 @@ export const entityQueryPolicies = Object.freeze({
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {'user'|'avatar'|'world'|'group'|'groupCollection'|'worldCollection'|'friendList'|'favoriteCollection'|'galleryCollection'|'inventoryCollection'|'fileObject'} entity
|
||||
* @returns {{staleTime: number, gcTime: number, retry: number, refetchOnWindowFocus: boolean}}
|
||||
*/
|
||||
export function getEntityQueryPolicy(entity) {
|
||||
return entityQueryPolicies[entity];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{staleTime: number, gcTime: number, retry: number, refetchOnWindowFocus: boolean}} policy
|
||||
* @returns {{staleTime: number, gcTime: number, retry: number, refetchOnWindowFocus: boolean}}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { AppDebug } from '../../service/appConfig.js';
|
||||
import { compareUnityVersion } from './avatar';
|
||||
import { getAvailablePlatforms } from './platformUtils';
|
||||
import { i18n } from '../../plugin/i18n';
|
||||
import { miscRequest } from '../../api';
|
||||
import { queryRequest } from '../../api';
|
||||
|
||||
/**
|
||||
* @param {string} fileName
|
||||
@@ -263,7 +263,7 @@ async function getBundleDateSize(ref) {
|
||||
if (!fileId || !version) {
|
||||
continue;
|
||||
}
|
||||
const args = await miscRequest.getFileAnalysis({
|
||||
const args = await queryRequest.fetch('fileAnalysis', {
|
||||
fileId,
|
||||
version,
|
||||
variant
|
||||
|
||||
@@ -249,8 +249,8 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
||||
*/
|
||||
async function getAvatarGallery(avatarId) {
|
||||
const D = avatarDialog.value;
|
||||
const args = await avatarRequest
|
||||
.getAvatarGallery(avatarId)
|
||||
const args = await queryRequest
|
||||
.fetch('avatarGallery', { avatarId })
|
||||
.finally(() => {
|
||||
D.galleryLoading = false;
|
||||
});
|
||||
|
||||
@@ -841,8 +841,8 @@ export const useUserStore = defineStore('User', () => {
|
||||
});
|
||||
if (!currentUser.value.hasSharedConnectionsOptOut) {
|
||||
try {
|
||||
userRequest
|
||||
.getMutualCounts({ userId })
|
||||
queryRequest
|
||||
.fetch('mutualCounts', { userId })
|
||||
.then((args) => {
|
||||
if (args.params.userId === D.id) {
|
||||
D.mutualFriendCount =
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
parseLocation,
|
||||
sanitizeEntityJson
|
||||
} from '../shared/utils';
|
||||
import { instanceRequest, miscRequest, worldRequest } from '../api';
|
||||
import { instanceRequest, queryRequest, worldRequest } from '../api';
|
||||
import { database } from '../service/database';
|
||||
import { patchWorldFromEvent } from '../queries';
|
||||
import { processBulk } from '../service/request';
|
||||
@@ -190,8 +190,8 @@ export const useWorldStore = defineStore('World', () => {
|
||||
D.isQuest = isQuest;
|
||||
D.isIos = isIos;
|
||||
updateVRChatWorldCache();
|
||||
miscRequest
|
||||
.hasWorldPersistData({
|
||||
queryRequest
|
||||
.fetch('worldPersistData', {
|
||||
worldId: D.id
|
||||
})
|
||||
.then((args) => {
|
||||
|
||||
@@ -376,10 +376,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Languages, Package, RefreshCcw, Settings, Trash2 } from 'lucide-vue-next';
|
||||
import { Languages, RefreshCcw, Trash2 } from 'lucide-vue-next';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ButtonGroup } from '@/components/ui/button-group';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
@@ -395,7 +394,6 @@
|
||||
useGeneralSettingsStore,
|
||||
useGroupStore,
|
||||
useInstanceStore,
|
||||
useLaunchStore,
|
||||
useNotificationsSettingsStore,
|
||||
usePhotonStore,
|
||||
useUiStore,
|
||||
@@ -405,7 +403,7 @@
|
||||
useVrcxStore,
|
||||
useWorldStore
|
||||
} from '../../../../stores';
|
||||
import { authRequest, miscRequest } from '../../../../api';
|
||||
import { authRequest, queryRequest } from '../../../../api';
|
||||
import { openExternalLink } from '../../../../shared/utils';
|
||||
|
||||
import AvatarProviderDialog from '../../dialogs/AvatarProviderDialog.vue';
|
||||
@@ -420,10 +418,9 @@
|
||||
const advancedSettingsStore = useAdvancedSettingsStore();
|
||||
const notificationsSettingsStore = useNotificationsSettingsStore();
|
||||
const { updateVRLastLocation, updateOpenVR } = useVrStore();
|
||||
const { showLaunchOptions } = useLaunchStore();
|
||||
const { enablePrimaryPasswordChange } = useAuthStore();
|
||||
const { cachedConfig } = storeToRefs(useAuthStore());
|
||||
const { clearVRCXCache, showRegistryBackupDialog } = useVrcxStore();
|
||||
const { clearVRCXCache } = useVrcxStore();
|
||||
const { showConsole } = useUiStore();
|
||||
const { disableGameLogDialog } = useGameLogStore();
|
||||
|
||||
@@ -576,7 +573,7 @@
|
||||
*
|
||||
*/
|
||||
function getVisits() {
|
||||
miscRequest.getVisits().then((args) => {
|
||||
queryRequest.fetch('visits').then((args) => {
|
||||
visits.value = args.json;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@
|
||||
|
||||
import { formatDateFilter, getGroupName, replaceBioSymbols } from '../../../shared/utils';
|
||||
import { Switch } from '../../../components/ui/switch';
|
||||
import { groupRequest } from '../../../api';
|
||||
import { processBulk } from '../../../service/request';
|
||||
import { queryRequest } from '../../../api';
|
||||
import { useGroupStore } from '../../../stores';
|
||||
|
||||
import GroupCalendarEventCard from '../components/GroupCalendarEventCard.vue';
|
||||
@@ -142,6 +142,9 @@
|
||||
showFeaturedEvents.value = await configRepository.getBool('VRCX_groupCalendarShowFeaturedEvents', false);
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function toggleFeaturedEvents() {
|
||||
configRepository.setBool('VRCX_groupCalendarShowFeaturedEvents', showFeaturedEvents.value);
|
||||
updateCalenderData();
|
||||
@@ -171,6 +174,9 @@
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function updateCalenderData() {
|
||||
isLoading.value = true;
|
||||
let fetchPromises = [getCalendarData(), getFollowingCalendarData()];
|
||||
@@ -332,17 +338,24 @@
|
||||
// Use a stable key for calendar maps (independent of locale/appearance date formatting).
|
||||
const formatDateKey = (date) => dayjs(date).format('YYYY-MM-DD');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param groupId
|
||||
*/
|
||||
async function getGroupNameFromCache(groupId) {
|
||||
if (!groupNamesCache.has(groupId)) {
|
||||
groupNamesCache.set(groupId, await getGroupName(groupId));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function getCalendarData() {
|
||||
calendar.value = [];
|
||||
try {
|
||||
await processBulk({
|
||||
fn: groupRequest.getGroupCalendars,
|
||||
fn: (bulkParams) => queryRequest.fetch('groupCalendars', bulkParams),
|
||||
N: -1,
|
||||
params: {
|
||||
n: 100,
|
||||
@@ -364,11 +377,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function getFollowingCalendarData() {
|
||||
followingCalendar.value = [];
|
||||
try {
|
||||
await processBulk({
|
||||
fn: groupRequest.getFollowingGroupCalendars,
|
||||
fn: (bulkParams) => queryRequest.fetch('followingGroupCalendars', bulkParams),
|
||||
N: -1,
|
||||
params: {
|
||||
n: 100,
|
||||
@@ -388,11 +404,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function getFeaturedCalendarData() {
|
||||
featuredCalendar.value = [];
|
||||
try {
|
||||
await processBulk({
|
||||
fn: groupRequest.getFeaturedGroupCalendars,
|
||||
fn: (bulkParams) => queryRequest.fetch('featuredGroupCalendars', bulkParams),
|
||||
N: -1,
|
||||
params: {
|
||||
n: 100,
|
||||
@@ -412,6 +431,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param updatedEvent
|
||||
*/
|
||||
function updateFollowingCalendarData(updatedEvent) {
|
||||
const index = followingCalendar.value.findIndex((item) => item.id === updatedEvent.id);
|
||||
if (index !== -1) {
|
||||
@@ -422,14 +445,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param eventId
|
||||
*/
|
||||
function isEventFollowing(eventId) {
|
||||
return followingCalendar.value.some((item) => item.id === eventId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function toggleViewMode() {
|
||||
viewMode.value = viewMode.value === 'timeline' ? 'grid' : 'timeline';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param groupId
|
||||
*/
|
||||
function toggleGroup(groupId) {
|
||||
groupCollapsed.value = {
|
||||
...groupCollapsed.value,
|
||||
@@ -437,6 +471,9 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function closeDialog() {
|
||||
emit('close');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user