refactor queryRequest

This commit is contained in:
pa
2026-03-09 21:28:45 +09:00
parent c1a35223d4
commit 58b9bdc1c5
60 changed files with 1134 additions and 883 deletions

View File

@@ -19,8 +19,8 @@ import { createOverlayDispatch } from '../notification/overlayDispatch';
function makeDeps(overrides = {}) {
return {
getUserIdFromNoty: vi.fn(() => ''),
userRequest: {
getCachedUser: vi.fn().mockResolvedValue({ json: null })
queryRequest: {
fetch: vi.fn().mockResolvedValue({ json: null })
},
notificationsSettingsStore: {
notificationTimeout: 5000
@@ -66,7 +66,7 @@ describe('notyGetImage', () => {
test('looks up user currentAvatarThumbnailImageUrl when no image URLs', async () => {
deps.getUserIdFromNoty.mockReturnValue('usr_abc');
deps.userRequest.getCachedUser.mockResolvedValue({
deps.queryRequest.fetch.mockResolvedValue({
json: {
currentAvatarThumbnailImageUrl: 'https://avatar.jpg'
}
@@ -80,7 +80,7 @@ describe('notyGetImage', () => {
test('returns profilePicOverride when available', async () => {
deps.getUserIdFromNoty.mockReturnValue('usr_abc');
deps.userRequest.getCachedUser.mockResolvedValue({
deps.queryRequest.fetch.mockResolvedValue({
json: {
profilePicOverride: 'https://profile.jpg',
currentAvatarThumbnailImageUrl: 'https://avatar.jpg'
@@ -95,7 +95,7 @@ describe('notyGetImage', () => {
test('returns userIcon when displayVRCPlusIconsAsAvatar is enabled', async () => {
deps.getUserIdFromNoty.mockReturnValue('usr_abc');
deps.appearanceSettingsStore.displayVRCPlusIconsAsAvatar = true;
deps.userRequest.getCachedUser.mockResolvedValue({
deps.queryRequest.fetch.mockResolvedValue({
json: {
userIcon: 'https://icon.jpg',
profilePicOverride: 'https://profile.jpg',
@@ -114,12 +114,12 @@ describe('notyGetImage', () => {
const result = await dispatch.notyGetImage({});
expect(result).toBe('');
expect(deps.userRequest.getCachedUser).not.toHaveBeenCalled();
expect(deps.queryRequest.fetch).not.toHaveBeenCalled();
});
test('returns empty string when user lookup fails', async () => {
deps.getUserIdFromNoty.mockReturnValue('usr_abc');
deps.userRequest.getCachedUser.mockRejectedValue(
deps.queryRequest.fetch.mockRejectedValue(
new Error('Network error')
);
dispatch = createOverlayDispatch(deps);
@@ -130,7 +130,7 @@ describe('notyGetImage', () => {
test('returns empty string when user has no json', async () => {
deps.getUserIdFromNoty.mockReturnValue('usr_abc');
deps.userRequest.getCachedUser.mockResolvedValue({ json: null });
deps.queryRequest.fetch.mockResolvedValue({ json: null });
dispatch = createOverlayDispatch(deps);
const result = await dispatch.notyGetImage({});

View File

@@ -14,7 +14,7 @@ import {
sanitizeEntityJson,
storeAvatarImage
} from '../shared/utils';
import { avatarRequest, miscRequest } from '../api';
import { avatarRequest, miscRequest, queryRequest } from '../api';
import { AppDebug } from '../service/appConfig';
import { database } from '../service/database';
import { patchAvatarFromEvent } from '../queries';
@@ -174,7 +174,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
}
const loadAvatarRequest = forceRefresh
? avatarRequest.getAvatar({ avatarId })
: avatarRequest.getCachedAvatar({ avatarId });
: queryRequest.fetch('avatar', { avatarId });
loadAvatarRequest
.then((args) => {
const ref = applyAvatar(args.json);
@@ -312,6 +312,9 @@ export const useAvatarStore = defineStore('Avatar', () => {
return ref;
}
/**
*
*/
function resetCachedAvatarModerations() {
cachedAvatarModerations.clear();
}

View File

@@ -10,7 +10,7 @@ import {
removeFromArray,
replaceReactiveObject
} from '../shared/utils';
import { avatarRequest, favoriteRequest } from '../api';
import { avatarRequest, favoriteRequest, queryRequest } from '../api';
import { database } from '../service/database';
import { processBulk } from '../service/request';
import { useAppearanceSettingsStore } from './settings/appearance';
@@ -771,7 +771,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
}
isFavoriteLoading.value = true;
try {
const args = await favoriteRequest.getCachedFavoriteLimits();
const args = await queryRequest.fetch('favoriteLimits');
favoriteLimits.value = {
...favoriteLimits.value,
...args.json
@@ -781,7 +781,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
}
let newFavoriteSortOrder = [];
processBulk({
fn: favoriteRequest.getCachedFavorites,
fn: (params) => queryRequest.fetch('favorites', params),
N: -1,
params: {
n: 300,
@@ -884,7 +884,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
offset: 0,
tag
};
const args = await favoriteRequest.getCachedFavoriteAvatars(params);
const args = await queryRequest.fetch('favoriteAvatars', params);
handleFavoriteAvatarList(args);
}

View File

@@ -16,7 +16,7 @@ import {
isRealInstance,
migrateMemos
} from '../shared/utils';
import { friendRequest, userRequest } from '../api';
import { friendRequest, queryRequest, userRequest } from '../api';
import { AppDebug } from '../service/appConfig';
import { createFriendPresenceCoordinator } from './coordinators/friendPresenceCoordinator';
import { createFriendRelationshipCoordinator } from './coordinators/friendRelationshipCoordinator';
@@ -259,6 +259,9 @@ export const useFriendStore = defineStore('Friend', () => {
{ flush: 'sync' }
);
/**
*
*/
async function init() {
const friendLogTableFiltersValue = JSON.parse(
await configRepository.getString('VRCX_friendLogTableFilters', '[]')
@@ -268,6 +271,10 @@ export const useFriendStore = defineStore('Friend', () => {
init();
/**
*
* @param ref
*/
function updateUserCurrentStatus(ref) {
if (watchState.isFriendsLoaded) {
refreshFriendsStatus(ref);
@@ -281,6 +288,10 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
* @param args
*/
function handleFriendStatus(args) {
const D = userStore.userDialog;
if (D.visible === false || D.id !== args.params.userId) {
@@ -292,6 +303,10 @@ export const useFriendStore = defineStore('Friend', () => {
D.outgoingRequest = json.outgoingRequest;
}
/**
*
* @param args
*/
function handleFriendDelete(args) {
const D = userStore.userDialog;
if (D.visible === false || D.id !== args.params.userId) {
@@ -302,11 +317,19 @@ export const useFriendStore = defineStore('Friend', () => {
deleteFriend(args.params.userId);
}
/**
*
* @param args
*/
function handleFriendAdd(args) {
addFriendship(args.params.userId);
addFriend(args.params.userId);
}
/**
*
* @param ref
*/
function userOnFriend(ref) {
updateFriendship(ref);
if (
@@ -337,6 +360,9 @@ export const useFriendStore = defineStore('Friend', () => {
return '';
}
/**
*
*/
function updateLocalFavoriteFriends() {
const favoriteStore = useFavoriteStore();
localFavoriteFriends.clear();
@@ -365,6 +391,9 @@ export const useFriendStore = defineStore('Friend', () => {
updateSidebarFavorites();
}
/**
*
*/
function updateSidebarFavorites() {
for (const ctx of friends.values()) {
const isVIP = localFavoriteFriends.has(ctx.id);
@@ -383,6 +412,9 @@ export const useFriendStore = defineStore('Friend', () => {
friendPresenceCoordinator.runUpdateFriendFlow(id, stateInput);
}
/**
*
*/
async function pendingOfflineWorkerFunction() {
pendingOfflineWorker = workerTimers.setInterval(() => {
friendPresenceCoordinator.runPendingOfflineTickFlow();
@@ -510,7 +542,7 @@ export const useFriendStore = defineStore('Friend', () => {
}
/**
* @param {Object} args
* @param {object} args
* @returns {Promise<*[]>}
*/
async function bulkRefreshFriends(args) {
@@ -528,10 +560,14 @@ export const useFriendStore = defineStore('Friend', () => {
intervalMs: 60_000
});
/**
*
* @param offset
*/
async function fetchPage(offset) {
const result = await executeWithBackoff(
async () => {
const { json } = await friendRequest.getCachedFriends({
const { json } = await queryRequest.fetch('friends', {
...args,
n: PAGE_SIZE,
offset
@@ -553,6 +589,9 @@ export const useFriendStore = defineStore('Friend', () => {
let stopFlag = false;
const friends = [];
/**
*
*/
function getNextOffset() {
if (stopFlag) return null;
const cur = nextOffset;
@@ -561,6 +600,9 @@ export const useFriendStore = defineStore('Friend', () => {
return cur;
}
/**
*
*/
async function worker() {
while (true) {
const offset = getNextOffset();
@@ -660,6 +702,10 @@ export const useFriendStore = defineStore('Friend', () => {
await friendSyncCoordinator.runRefreshFriendsListFlow();
}
/**
*
* @param forceUpdate
*/
function updateOnlineFriendCounter(forceUpdate = false) {
const onlineFriendCounts =
vipFriends.value.length + onlineFriends.value.length;
@@ -672,6 +718,9 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
*/
async function getAllUserStats() {
let ref;
let item;
@@ -741,6 +790,9 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
*/
async function getAllUserMutualCount() {
const mutualCountMap = await database.getMutualCountForAllUsers();
for (const [userId, mutualCount] of mutualCountMap.entries()) {
@@ -1027,6 +1079,9 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
*/
async function initFriendLogHistoryTable() {
friendLogTable.value.loading = true;
friendLogTable.value.data = await database.getFriendLogHistory();
@@ -1052,6 +1107,9 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
*/
async function tryApplyFriendOrder() {
const lastUpdate = await configRepository.getString(
`VRCX_lastStoreTime_${userStore.currentUser.id}`
@@ -1135,6 +1193,9 @@ export const useFriendStore = defineStore('Friend', () => {
);
}
/**
*
*/
async function restoreFriendNumber() {
let message;
let storedData = null;
@@ -1186,6 +1247,9 @@ export const useFriendStore = defineStore('Friend', () => {
return true;
}
/**
*
*/
function applyFriendLogFriendOrderInReverse() {
state.friendNumber = friends.size + 1;
const friendLogTable = getFriendLogFriendOrder();
@@ -1210,6 +1274,9 @@ export const useFriendStore = defineStore('Friend', () => {
console.log('Applied friend order from friendLog');
}
/**
*
*/
function getFriendLogFriendOrder() {
const result = [];
for (let i = 0; i < friendLogTable.value.data.length; i++) {
@@ -1235,6 +1302,12 @@ export const useFriendStore = defineStore('Friend', () => {
return result;
}
/**
*
* @param friendLogTable
* @param created_at
* @param backupUserIds
*/
function parseFriendOrderBackup(friendLogTable, created_at, backupUserIds) {
let i;
const backupTable = [];
@@ -1296,6 +1369,10 @@ export const useFriendStore = defineStore('Friend', () => {
};
}
/**
*
* @param userIdOrder
*/
function applyFriendOrderBackup(userIdOrder) {
for (let i = 0; i < userIdOrder.length; i++) {
const userId = userIdOrder[i];
@@ -1316,6 +1393,9 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
*/
function applyFriendLogFriendOrder() {
const friendLogTable = getFriendLogFriendOrder();
if (state.friendNumber === 0) {
@@ -1339,6 +1419,10 @@ export const useFriendStore = defineStore('Friend', () => {
}
}
/**
*
* @param id
*/
function confirmDeleteFriend(id) {
modalStore
.confirm({
@@ -1355,6 +1439,9 @@ export const useFriendStore = defineStore('Friend', () => {
.catch(() => {});
}
/**
*
*/
async function initFriendsList() {
await friendSyncCoordinator.runInitFriendsListFlow();
}

View File

@@ -9,12 +9,7 @@ import {
getPrintLocalDate,
openExternalLink
} from '../shared/utils';
import {
inventoryRequest,
userRequest,
vrcPlusIconRequest,
vrcPlusImageRequest
} from '../api';
import { queryRequest, vrcPlusImageRequest } from '../api';
import { AppDebug } from '../service/appConfig';
import { handleImageUploadInput } from '../shared/utils/imageUpload';
import { router } from '../plugin/router';
@@ -22,8 +17,6 @@ import { useAdvancedSettingsStore } from './settings/advanced';
import { useModalStore } from './modal';
import { watchState } from '../service/watchState';
import miscReq from '../api/misc';
import * as workerTimers from 'worker-timers';
export const useGalleryStore = defineStore('Gallery', () => {
@@ -100,6 +93,10 @@ export const useGalleryStore = defineStore('Gallery', () => {
{ flush: 'sync' }
);
/**
*
* @param args
*/
function handleFilesList(args) {
if (args.params.tag === 'gallery') {
galleryTable.value = args.json.reverse();
@@ -117,12 +114,19 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
* @param args
*/
function handleGalleryImageAdd(args) {
if (Object.keys(galleryTable.value).length !== 0) {
galleryTable.value.unshift(args.json);
}
}
/**
*
*/
function showGalleryPage() {
galleryDialogVisible.value = true;
if (router.currentRoute.value?.name === 'gallery') {
@@ -132,6 +136,9 @@ export const useGalleryStore = defineStore('Gallery', () => {
router.push({ name: 'gallery' });
}
/**
*
*/
function loadGalleryData() {
refreshGalleryTable();
refreshVRCPlusIconsTable();
@@ -141,14 +148,17 @@ export const useGalleryStore = defineStore('Gallery', () => {
getInventory();
}
/**
*
*/
function refreshGalleryTable() {
galleryDialogGalleryLoading.value = true;
const params = {
n: 100,
tag: 'gallery'
};
vrcPlusIconRequest
.getCachedFileList(params)
queryRequest
.fetch('galleryFiles', params)
.then((args) => handleFilesList(args))
.catch((error) => {
console.error('Error fetching gallery files:', error);
@@ -158,14 +168,17 @@ export const useGalleryStore = defineStore('Gallery', () => {
});
}
/**
*
*/
function refreshVRCPlusIconsTable() {
galleryDialogIconsLoading.value = true;
const params = {
n: 100,
tag: 'icon'
};
vrcPlusIconRequest
.getCachedFileList(params)
queryRequest
.fetch('galleryFiles', params)
.then((args) => handleFilesList(args))
.catch((error) => {
console.error('Error fetching VRC Plus icons:', error);
@@ -175,6 +188,10 @@ export const useGalleryStore = defineStore('Gallery', () => {
});
}
/**
*
* @param e
*/
function inviteImageUpload(e) {
const { file } = handleImageUploadInput(e, {
inputSelector: null,
@@ -192,6 +209,9 @@ export const useGalleryStore = defineStore('Gallery', () => {
r.readAsBinaryString(file);
}
/**
*
*/
function clearInviteImageUpload() {
const buttonList = document.querySelectorAll(
'.inviteImageUploadButton'
@@ -200,14 +220,17 @@ export const useGalleryStore = defineStore('Gallery', () => {
uploadImage.value = '';
}
/**
*
*/
function refreshStickerTable() {
galleryDialogStickersLoading.value = true;
const params = {
n: 100,
tag: 'sticker'
};
vrcPlusIconRequest
.getCachedFileList(params)
queryRequest
.fetch('galleryFiles', params)
.then((args) => handleFilesList(args))
.catch((error) => {
console.error('Error fetching stickers:', error);
@@ -217,12 +240,22 @@ export const useGalleryStore = defineStore('Gallery', () => {
});
}
/**
*
* @param args
*/
function handleStickerAdd(args) {
if (Object.keys(stickerTable.value).length !== 0) {
stickerTable.value.unshift(args.json);
}
}
/**
*
* @param displayName
* @param userId
* @param inventoryId
*/
async function trySaveStickerToFile(displayName, userId, inventoryId) {
if (instanceStickersCache.value.includes(inventoryId)) {
return;
@@ -231,7 +264,7 @@ export const useGalleryStore = defineStore('Gallery', () => {
if (instanceStickersCache.value.length > 100) {
instanceStickersCache.value.shift();
}
const args = await inventoryRequest.getCachedUserInventoryItem({
const args = await queryRequest.fetch('userInventoryItem', {
inventoryId,
userId
});
@@ -262,13 +295,16 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
*/
async function refreshPrintTable() {
galleryDialogPrintsLoading.value = true;
const params = {
n: 100
};
try {
const args = await vrcPlusImageRequest.getCachedPrints(params);
const args = await queryRequest.fetch('prints', params);
args.json.sort((a, b) => {
return (
new Date(b.timestamp).getTime() -
@@ -283,6 +319,10 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
* @param printId
*/
function queueSavePrintToFile(printId) {
if (state.printCache.includes(printId)) {
return;
@@ -304,8 +344,12 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
* @param printId
*/
async function trySavePrintToFile(printId) {
const args = await vrcPlusImageRequest.getCachedPrint({ printId });
const args = await queryRequest.fetch('print', { printId });
const imageUrl = args.json?.files?.image;
if (!imageUrl) {
console.error('Print image URL is missing', args);
@@ -314,7 +358,7 @@ export const useGalleryStore = defineStore('Gallery', () => {
const print = args.json;
const createdAt = getPrintLocalDate(print);
try {
const owner = await userRequest.getCachedUser({
const owner = await queryRequest.fetch('user', {
userId: print.ownerId
});
console.log(
@@ -349,14 +393,17 @@ export const useGalleryStore = defineStore('Gallery', () => {
// #endregion
// #region | Emoji
/**
*
*/
function refreshEmojiTable() {
galleryDialogEmojisLoading.value = true;
const params = {
n: 100,
tag: 'emoji'
};
vrcPlusIconRequest
.getCachedFileList(params)
queryRequest
.fetch('galleryFiles', params)
.then((args) => handleFilesList(args))
.catch((error) => {
console.error('Error fetching emojis:', error);
@@ -366,6 +413,9 @@ export const useGalleryStore = defineStore('Gallery', () => {
});
}
/**
*
*/
async function getInventory() {
inventoryTable.value = [];
advancedSettingsStore.currentUserInventory.clear();
@@ -378,8 +428,7 @@ export const useGalleryStore = defineStore('Gallery', () => {
try {
for (let i = 0; i < 100; i++) {
params.offset = i * params.n;
const args =
await inventoryRequest.getCachedInventoryItems(params);
const args = await queryRequest.fetch('inventoryItems', params);
for (const item of args.json.data) {
advancedSettingsStore.currentUserInventory.set(
item.id,
@@ -400,6 +449,9 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
*/
async function tryDeleteOldPrints() {
if (!advancedSettingsStore.autoDeleteOldPrints) {
return;
@@ -435,6 +487,11 @@ export const useGalleryStore = defineStore('Gallery', () => {
await refreshPrintTable();
}
/**
*
* @param imageUrl
* @param fileName
*/
function showFullscreenImageDialog(imageUrl, fileName) {
if (!imageUrl) {
return;
@@ -445,6 +502,11 @@ export const useGalleryStore = defineStore('Gallery', () => {
D.visible = true;
}
/**
*
* @param inventoryId
* @param userId
*/
function queueCheckInstanceInventory(inventoryId, userId) {
if (
state.instanceInventoryCache.includes(inventoryId) ||
@@ -472,8 +534,13 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
* @param inventoryId
* @param userId
*/
async function trySaveEmojiToFile(inventoryId, userId) {
const args = await inventoryRequest.getCachedUserInventoryItem({
const args = await queryRequest.fetch('userInventoryItem', {
inventoryId,
userId
});
@@ -486,7 +553,7 @@ export const useGalleryStore = defineStore('Gallery', () => {
return;
}
const userArgs = await userRequest.getCachedUser({
const userArgs = await queryRequest.fetch('user', {
userId: args.json.holderId
});
const displayName = userArgs.json?.displayName ?? '';
@@ -537,6 +604,10 @@ export const useGalleryStore = defineStore('Gallery', () => {
}
}
/**
*
* @param fileId
*/
async function getCachedEmoji(fileId) {
return new Promise((resolve, reject) => {
let ref = cachedEmoji.get(fileId);
@@ -544,8 +615,8 @@ export const useGalleryStore = defineStore('Gallery', () => {
resolve(ref);
return;
}
miscReq
.getCachedFile({ fileId })
queryRequest
.fetch('file', { fileId })
.then((args) => {
cachedEmoji.set(fileId, args.json);
resolve(args.json);

View File

@@ -10,12 +10,7 @@ import {
replaceBioSymbols,
sanitizeEntityJson
} from '../shared/utils';
import {
groupRequest,
instanceRequest,
userRequest,
worldRequest
} from '../api';
import { groupRequest, instanceRequest, queryRequest } from '../api';
import { database } from '../service/database';
import { groupDialogFilterOptions } from '../shared/constants/';
import { patchGroupFromEvent } from '../queries';
@@ -195,8 +190,8 @@ export const useGroupStore = defineStore('Group', () => {
D.ownerDisplayName = ref.ownerId;
D.visible = true;
D.loading = false;
userRequest
.getCachedUser({
queryRequest
.fetch('user', {
userId: ref.ownerId
})
.then((args1) => {
@@ -221,10 +216,10 @@ export const useGroupStore = defineStore('Group', () => {
* @returns {Promise<void>}
*/
async function groupOwnerChange(ref, oldUserId, newUserId) {
const oldUser = await userRequest.getCachedUser({
const oldUser = await queryRequest.fetch('user', {
userId: oldUserId
});
const newUser = await userRequest.getCachedUser({
const newUser = await queryRequest.fetch('user', {
userId: newUserId
});
const oldDisplayName = oldUser?.ref?.displayName;
@@ -422,7 +417,7 @@ export const useGroupStore = defineStore('Group', () => {
let total = Infinity;
let pages = 0;
do {
const args = await groupRequest.getCachedGroupPosts({
const args = await queryRequest.fetch('groupPosts', {
groupId: params.groupId,
n,
offset
@@ -466,8 +461,8 @@ export const useGroupStore = defineStore('Group', () => {
const refPromise = existingRef
? Promise.resolve({ ref: existingRef })
: groupRequest
.getCachedGroup({ groupId, includeRoles: true })
: queryRequest
.fetch('group', { groupId, includeRoles: true })
.then((args) => ({ ref: applyGroup(args.json), args }));
return refPromise
@@ -507,8 +502,8 @@ export const useGroupStore = defineStore('Group', () => {
}
for (const json of args.json.instances) {
instanceStore.applyInstance(json);
worldRequest
.getCachedWorld({
queryRequest
.fetch('world', {
worldId: json.world.id
})
.then((args1) => {
@@ -521,16 +516,16 @@ export const useGroupStore = defineStore('Group', () => {
});
}
});
groupRequest
.getCachedGroupCalendar(groupId)
queryRequest
.fetch('groupCalendar', { groupId })
.then((args) => {
if (groupDialog.value.id === args.params.groupId) {
D.calendar = args.json.results;
for (const event of D.calendar) {
applyGroupEvent(event);
// fetch again for isFollowing
groupRequest
.getCachedGroupCalendarEvent({
queryRequest
.fetch('groupCalendarEvent', {
groupId,
eventId: event.id
})
@@ -1175,7 +1170,7 @@ export const useGroupStore = defineStore('Group', () => {
D.groupRef = {};
D.auditLogTypes = [];
groupRequest.getCachedGroup({ groupId }).then((args) => {
queryRequest.fetch('group', { groupId }).then((args) => {
D.groupRef = args.ref;
if (hasGroupPermission(D.groupRef, 'group-audit-view')) {
groupRequest.getGroupAuditLogTypes({ groupId }).then((args) => {

View File

@@ -23,8 +23,8 @@ import {
replaceBioSymbols
} from '../shared/utils';
import {
groupRequest,
instanceRequest,
queryRequest,
userRequest,
worldRequest
} from '../api';
@@ -33,7 +33,6 @@ import {
instanceContentSettings
} from '../shared/constants';
import { database } from '../service/database';
import { patchInstanceFromEvent } from '../queries';
import { resolveRef } from '../shared/utils/resolveRef';
import { useAppearanceSettingsStore } from './settings/appearance';
import { useFriendStore } from './friend';
@@ -246,7 +245,7 @@ export const useInstanceStore = defineStore('Instance', () => {
emptyDefault: { id: '', displayName: '' },
idAlias: 'userId',
nameKey: 'displayName',
fetchFn: (id) => userRequest.getCachedUser({ userId: id })
fetchFn: (id) => queryRequest.fetch('user', { userId: id })
});
}
@@ -259,7 +258,7 @@ export const useInstanceStore = defineStore('Instance', () => {
emptyDefault: { id: '', name: '' },
idAlias: 'worldId',
nameKey: 'name',
fetchFn: (id) => worldRequest.getCachedWorld({ worldId: id })
fetchFn: (id) => queryRequest.fetch('world', { worldId: id })
});
}
@@ -272,7 +271,7 @@ export const useInstanceStore = defineStore('Instance', () => {
emptyDefault: { id: '', name: '' },
idAlias: 'groupId',
nameKey: 'name',
fetchFn: (id) => groupRequest.getCachedGroup({ groupId: id })
fetchFn: (id) => queryRequest.fetch('group', { groupId: id })
});
}
@@ -340,8 +339,8 @@ export const useInstanceStore = defineStore('Instance', () => {
location.worldId &&
!worldStore.cachedWorlds.get(location.worldId)?.name
) {
worldRequest
.getCachedWorld({ worldId: location.worldId })
queryRequest
.fetch('world', { worldId: location.worldId })
.then((args) => {
uiStore.setDialogCrumbLabel(
'previous-instances-info',
@@ -467,8 +466,8 @@ export const useInstanceStore = defineStore('Instance', () => {
console.error('Error fetching world data:', error);
});
} else {
worldRequest
.getCachedWorld({
queryRequest
.fetch('world', {
worldId: currentInstanceLocation.value.worldId
})
.then((args) => {
@@ -537,8 +536,8 @@ export const useInstanceStore = defineStore('Instance', () => {
}
ref.$location = parseLocation(ref.location);
if (ref.world?.id) {
worldRequest
.getCachedWorld({
queryRequest
.fetch('world', {
worldId: ref.world.id
})
.then((args) => {
@@ -577,7 +576,6 @@ export const useInstanceStore = defineStore('Instance', () => {
}
}
lastInstanceApplied.value = ref.id;
patchInstanceFromEvent(ref);
return ref;
}
@@ -591,7 +589,7 @@ export const useInstanceStore = defineStore('Instance', () => {
const L = parseLocation(location);
if (L.isRealInstance && L.worldId && L.instanceId) {
try {
const args = await instanceRequest.getCachedInstance({
const args = await instanceRequest.getInstance({
worldId: L.worldId,
instanceId: L.instanceId
});

View File

@@ -23,8 +23,7 @@ import {
friendRequest,
instanceRequest,
notificationRequest,
userRequest,
worldRequest
queryRequest
} from '../../api';
import {
getNotificationMessage,
@@ -216,7 +215,7 @@ export const useNotificationStore = defineStore('Notification', () => {
// get instance name for invite
const L = parseLocation(ref.details.worldId);
if (L.isRealInstance) {
instanceRequest.getCachedInstance({
instanceRequest.getInstance({
worldId: L.worldId,
instanceId: L.instanceId
});
@@ -350,8 +349,8 @@ export const useNotificationStore = defineStore('Notification', () => {
}
const L = parseLocation(currentLocation);
worldRequest
.getCachedWorld({
queryRequest
.fetch('world', {
worldId: L.worldId
})
.then((args1) => {
@@ -401,6 +400,9 @@ export const useNotificationStore = defineStore('Notification', () => {
notificationInitStatus.value = value;
}
/**
*
*/
function clearUnseenNotifications() {
unseenNotifications.value = [];
}
@@ -996,7 +998,7 @@ export const useNotificationStore = defineStore('Notification', () => {
displayOvrtNotification
} = createOverlayDispatch({
getUserIdFromNoty,
userRequest,
queryRequest,
notificationsSettingsStore,
advancedSettingsStore,
appearanceSettingsStore
@@ -1285,8 +1287,8 @@ export const useNotificationStore = defineStore('Notification', () => {
currentLocation = userStore.currentUser?.$locationTag;
}
const L = parseLocation(currentLocation);
worldRequest
.getCachedWorld({ worldId: L.worldId })
queryRequest
.fetch('world', { worldId: L.worldId })
.then((args) => {
notificationRequest
.sendInvite(

View File

@@ -6,10 +6,9 @@ import {
/**
* Creates the overlay dispatch functions for the Notification store.
*
* @param {object} deps
* @param {Function} deps.getUserIdFromNoty
* @param {object} deps.userRequest
* @param {object} deps.queryRequest
* @param {object} deps.notificationsSettingsStore
* @param {object} deps.advancedSettingsStore
* @param {object} deps.appearanceSettingsStore
@@ -17,7 +16,7 @@ import {
*/
export function createOverlayDispatch({
getUserIdFromNoty,
userRequest,
queryRequest,
notificationsSettingsStore,
advancedSettingsStore,
appearanceSettingsStore
@@ -54,6 +53,12 @@ export function createOverlayDispatch({
return imageLocation;
}
/**
*
* @param noty
* @param message
* @param image
*/
function displayDesktopToast(noty, message, image) {
const result = getNotificationMessage(noty, message);
if (result) {
@@ -100,6 +105,14 @@ export function createOverlayDispatch({
AppApi.XSNotification('VRCX', text, timeout, opacity, image);
}
/**
*
* @param playOvrtHudNotifications
* @param playOvrtWristNotifications
* @param noty
* @param message
* @param image
*/
function displayOvrtNotification(
playOvrtHudNotifications,
playOvrtWristNotifications,
@@ -146,8 +159,8 @@ export function createOverlayDispatch({
} else if (noty.imageUrl) {
imageUrl = noty.imageUrl;
} else if (userId && !userId.startsWith('grp_')) {
imageUrl = await userRequest
.getCachedUser({
imageUrl = await queryRequest
.fetch('user', {
userId
})
.catch((err) => {

View File

@@ -19,12 +19,12 @@ import {
ActivityType,
StatusDisplayType
} from '../../shared/constants/discord';
import { queryRequest } from '../../api';
import { useGameLogStore } from '../gameLog';
import { useGameStore } from '../game';
import { useLocationStore } from '../location';
import { useUpdateLoopStore } from '../updateLoop';
import { useUserStore } from '../user';
import { worldRequest } from '../../api';
import configRepository from '../../service/config';
@@ -221,7 +221,7 @@ export const useDiscordPresenceSettingsStore = defineStore(
groupAccessName: ''
};
try {
const args = await worldRequest.getCachedWorld({
const args = await queryRequest.fetch('world', {
worldId: L.worldId
});
state.lastLocationDetails.worldName = args.ref.name;

View File

@@ -29,6 +29,7 @@ import {
avatarRequest,
groupRequest,
instanceRequest,
queryRequest,
userRequest
} from '../api';
import { processBulk, request } from '../service/request';
@@ -715,8 +716,8 @@ export const useUserStore = defineStore('User', () => {
});
}
AppApi.SendIpc('ShowUserDialog', userId);
userRequest
.getCachedUser({
queryRequest
.fetch('user', {
userId
})
.catch((err) => {

View File

@@ -9,7 +9,7 @@ import {
SEARCH_LIMIT_MAX,
SEARCH_LIMIT_MIN
} from '../shared/constants';
import { avatarRequest, worldRequest } from '../api';
import { avatarRequest, queryRequest } from '../api';
import {
clearPiniaActionTrail,
getPiniaActionTrail
@@ -684,7 +684,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
toast.error('Invalid local favorite world command');
break;
}
worldRequest.getCachedWorld({ worldId: id }).then(() => {
queryRequest.fetch('world', { worldId: id }).then(() => {
searchStore.directAccessWorld(id);
favoriteStore.addLocalWorldFavorite(id, group);
});