refactor: app.js (#1291)

* refactor: frontend

* Fix avatar gallery sort

* Update .NET dependencies

* Update npm dependencies

electron v37.1.0

* bulkRefreshFriends

* fix dark theme

* Remove crowdin

* Fix config.json dialog not updating

* VRCX log file fixes & add Cef log

* Remove SharedVariable, fix startup

* Revert init theme change

* Logging date not working? Fix WinformThemer designer error

* Add Cef request hander, no more escaping main page

* clean

* fix

* fix

* clean

* uh

* Apply thememode at startup, fixes random user colours

* Split database into files

* Instance info remove empty lines

* Open external VRC links with VRCX

* Electron fixes

* fix userdialog style

* ohhhh

* fix store

* fix store

* fix: load all group members after kicking a user

* fix: world dialog favorite button style

* fix: Clear VRCX Cache Timer input value

* clean

* Fix VR overlay

* Fix VR overlay 2

* Fix Discord discord rich presence for RPC worlds

* Clean up age verified user tags

* Fix playerList being occupied after program reload

* no `this`

* Fix login stuck loading

* writable: false

* Hide dialogs on logout

* add flush sync option

* rm LOGIN event

* rm LOGOUT event

* remove duplicate event listeners

* remove duplicate event listeners

* clean

* remove duplicate event listeners

* clean

* fix theme style

* fix t

* clearable

* clean

* fix ipcEvent

* Small changes

* Popcorn Palace support

* Remove checkActiveFriends

* Clean up

* Fix dragEnterCef

* Block API requests when not logged in

* Clear state on login & logout

* Fix worldDialog instances not updating

* use <script setup>

* Fix avatar change event, CheckGameRunning at startup

* Fix image dragging

* fix

* Remove PWI

* fix updateLoop

* add webpack-dev-server to dev environment

* rm unnecessary chunks

* use <script setup>

* webpack-dev-server changes

* use <script setup>

* use <script setup>

* Fix UGC text size

* Split login event

* t

* use <script setup>

* fix

* Update .gitignore and enable checkJs in jsconfig

* fix i18n t

* use <script setup>

* use <script setup>

* clean

* global types

* fix

* use checkJs for debugging

* Add watchState for login watchers

* fix .vue template

* type fixes

* rm Vue.filter

* Cef v138.0.170, VC++ 2022

* Settings fixes

* Remove 'USER:CURRENT'

* clean up 2FA callbacks

* remove userApply

* rm i18n import

* notification handling to use notification store methods

* refactor favorite handling to use favorite store methods and clean up event emissions

* refactor moderation handling to use dedicated functions for player moderation events

* refactor friend handling to use dedicated functions for friend events

* Fix program startup, move lang init

* Fix friend state

* Fix status change error

* Fix user notes diff

* fix

* rm group event

* rm auth event

* rm avatar event

* clean

* clean

* getUser

* getFriends

* getFavoriteWorlds, getFavoriteAvatars

* AvatarGalleryUpload btn style & package.json update

* Fix friend requests

* Apply user

* Apply world

* Fix note diff

* Fix VR overlay

* Fixes

* Update build scripts

* Apply avatar

* Apply instance

* Apply group

* update hidden VRC+ badge

* Fix sameInstance "private"

* fix 502/504 API errors

* fix 502/504 API errors

* clean

* Fix friend in same instance on orange showing twice in friends list

* Add back in broken friend state repair methods

* add types

---------

Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
pa
2025-07-14 12:00:08 +09:00
committed by GitHub
parent 952fd77ed5
commit f4f78bb5ec
323 changed files with 47745 additions and 43326 deletions

69
src/api/auth.js Normal file
View File

@@ -0,0 +1,69 @@
import { request } from '../service/request';
import { useUserStore } from '../stores';
const loginReq = {
/**
* @param {{ code: string }} params One-time password
* @returns {Promise<{json: any, params}>}
*/
verifyOTP(params) {
return request('auth/twofactorauth/otp/verify', {
method: 'POST',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
/**
* @param {{ code: string }} params One-time token
* @returns {Promise<{json: any, params}>}
*/
verifyTOTP(params) {
return request('auth/twofactorauth/totp/verify', {
method: 'POST',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
/**
* @param {{ code: string }} params One-time token
* @returns {Promise<{json: any, params}>}
*/
verifyEmailOTP(params) {
return request('auth/twofactorauth/emailotp/verify', {
method: 'POST',
params
}).then((json) => {
const args = {
json,
params
};
return args;
});
},
getConfig() {
return request('config', {
method: 'GET'
}).then((json) => {
const args = {
json
};
useUserStore().handleConfig(args);
return args;
});
}
};
export default loginReq;

View File

@@ -1,19 +1,18 @@
// #region | API: Avatar
import { request } from '../service/request';
import { useUserStore } from '../stores';
const avatarReq = {
/**
* @param {{ avatarId: string }} params
* @returns {Promise<{json: any, params}>}
* @type {import('../types/avatar').getAvatar}
*/
getAvatar(params) {
return window.API.call(`avatars/${params.avatarId}`, {
return request(`avatars/${params.avatarId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('AVATAR', args);
return args;
});
},
@@ -37,7 +36,7 @@ const avatarReq = {
* @returns {Promise<{json: any, params}>}
*/
getAvatars(params) {
return window.API.call('avatars', {
return request('avatars', {
method: 'GET',
params
}).then((json) => {
@@ -45,16 +44,16 @@ const avatarReq = {
json,
params
};
window.API.$emit('AVATAR:LIST', args);
return args;
});
},
/**
* @param {{ id: string, releaseStatus: 'public' | 'private' }} params
* @param {{ id: string, releaseStatus?: 'public' | 'private', name?: string, description?: string }} params
* @returns {Promise<{json: any, params}>}
*/
saveAvatar(params) {
return window.API.call(`avatars/${params.id}`, {
return request(`avatars/${params.id}`, {
method: 'PUT',
params
}).then((json) => {
@@ -62,7 +61,6 @@ const avatarReq = {
json,
params
};
window.API.$emit('AVATAR:SAVE', args);
return args;
});
},
@@ -72,7 +70,8 @@ const avatarReq = {
* @returns {Promise<{json: any, params}>}
*/
selectAvatar(params) {
return window.API.call(`avatars/${params.avatarId}/select`, {
const userStore = useUserStore();
return request(`avatars/${params.avatarId}/select`, {
method: 'PUT',
params
}).then((json) => {
@@ -80,7 +79,7 @@ const avatarReq = {
json,
params
};
window.API.$emit('AVATAR:SELECT', args);
userStore.applyCurrentUser(json);
return args;
});
},
@@ -90,7 +89,8 @@ const avatarReq = {
* @return { Promise<{json: any, params}> }
*/
selectFallbackAvatar(params) {
return window.API.call(`avatars/${params.avatarId}/selectfallback`, {
const userStore = useUserStore();
return request(`avatars/${params.avatarId}/selectfallback`, {
method: 'PUT',
params
}).then((json) => {
@@ -98,7 +98,7 @@ const avatarReq = {
json,
params
};
window.API.$emit('AVATAR:SELECT', args);
userStore.applyCurrentUser(json);
return args;
});
},
@@ -108,14 +108,13 @@ const avatarReq = {
* @return { Promise<{json: any, params}> }
*/
deleteAvatar(params) {
return window.API.call(`avatars/${params.avatarId}`, {
return request(`avatars/${params.avatarId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('AVATAR:DELETE', args);
return args;
});
},
@@ -125,14 +124,13 @@ const avatarReq = {
* @returns {Promise<{json: any, params}>}
*/
createImposter(params) {
return window.API.call(`avatars/${params.avatarId}/impostor/enqueue`, {
return request(`avatars/${params.avatarId}/impostor/enqueue`, {
method: 'POST'
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('AVATAR:IMPOSTER:CREATE', args);
return args;
});
},
@@ -142,35 +140,33 @@ const avatarReq = {
* @returns {Promise<{json: T, params}>}
*/
deleteImposter(params) {
return window.API.call(`avatars/${params.avatarId}/impostor`, {
return request(`avatars/${params.avatarId}/impostor`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('AVATAR:IMPOSTER:DELETE', args);
return args;
});
},
/**
* @returns {Promise<{json: any, params}>}
* @returns {Promise<{json: any}>}
*/
getAvailableAvatarStyles() {
return window.API.call('avatarStyles', {
return request('avatarStyles', {
method: 'GET'
}).then((json) => {
const args = {
json
};
// window.API.$emit('AVATAR:STYLES', args);
return args;
});
},
/**
* @param {{ avatarId: string }} params
* @param {{ avatarId: string }} avatarId
* @returns {Promise<{json: any, params}>}
*/
getAvatarGallery(avatarId) {
@@ -180,7 +176,7 @@ const avatarReq = {
n: 100,
offset: 0
};
return window.API.call(`files`, {
return request(`files`, {
params,
method: 'GET'
}).then((json) => {
@@ -188,7 +184,6 @@ const avatarReq = {
json,
params
};
// window.API.$emit('AVATAR:GALLERY', args);
return args;
});
},
@@ -202,7 +197,7 @@ const avatarReq = {
tag: 'avatargallery',
galleryId: avatarId
};
return window.API.call('file/image', {
return request('file/image', {
uploadImage: true,
matchingDimensions: false,
postData: JSON.stringify(params),
@@ -212,7 +207,6 @@ const avatarReq = {
json,
params
};
// window.API.$emit('AVATARGALLERYIMAGE:ADD', args);
return args;
});
},
@@ -225,7 +219,7 @@ const avatarReq = {
const params = {
ids: order
};
return window.API.call('files/order', {
return request('files/order', {
method: 'PUT',
params
}).then((json) => {
@@ -233,11 +227,9 @@ const avatarReq = {
json,
params
};
// window.API.$emit('AVATARGALLERYIMAGE:ORDER', args);
return args;
});
}
};
// #endregion
export default avatarReq;

View File

@@ -1,14 +1,13 @@
// #region | API: AvatarModeration
import { request } from '../service/request';
const avatarModerationReq = {
getAvatarModerations() {
return window.API.call('auth/user/avatarmoderations', {
return request('auth/user/avatarmoderations', {
method: 'GET'
}).then((json) => {
const args = {
json
};
// window.API.$emit('AVATAR-MODERATION:LIST', args);
return args;
});
},
@@ -18,7 +17,7 @@ const avatarModerationReq = {
* @return { Promise<{json: any, params}> }
*/
sendAvatarModeration(params) {
return window.API.call('auth/user/avatarmoderations', {
return request('auth/user/avatarmoderations', {
method: 'POST',
params
}).then((json) => {
@@ -26,7 +25,6 @@ const avatarModerationReq = {
json,
params
};
// window.API.$emit('AVATAR-MODERATION', args);
return args;
});
},
@@ -36,7 +34,7 @@ const avatarModerationReq = {
* @return { Promise<{json: any, params}> }
*/
deleteAvatarModeration(params) {
return window.API.call(
return request(
`auth/user/avatarmoderations?targetAvatarId=${encodeURIComponent(
params.targetAvatarId
)}&avatarModerationType=${encodeURIComponent(
@@ -50,11 +48,9 @@ const avatarModerationReq = {
json,
params
};
window.API.$emit('AVATAR-MODERATION:DELETE', args);
return args;
});
}
};
// #endregion
export default avatarModerationReq;

View File

@@ -1,29 +1,27 @@
// #region | API: Favorite
import { request } from '../service/request';
import { useFavoriteStore, useUserStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const favoriteReq = {
getFavoriteLimits() {
return window.API.call('auth/user/favoritelimits', {
return request('auth/user/favoritelimits', {
method: 'GET'
}).then((json) => {
const args = {
json
};
window.API.$emit('FAVORITE:LIMITS', args);
return args;
});
},
/**
* @param {{
* n: number,
* offset: number,
* type: string,
* tag: string
* }} params
* @return { Promise<{json: any, params}> }
* @type {import('../types/favorite').getFavorites}
*/
getFavorites(params) {
return window.API.call('favorites', {
return request('favorites', {
method: 'GET',
params
}).then((json) => {
@@ -31,7 +29,6 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:LIST', args);
return args;
});
},
@@ -45,7 +42,7 @@ const favoriteReq = {
* @return { Promise<{json: any, params}> }
*/
addFavorite(params) {
return window.API.call('favorites', {
return request('favorites', {
method: 'POST',
params
}).then((json) => {
@@ -53,7 +50,7 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:ADD', args);
useFavoriteStore().handleFavoriteAdd(args);
return args;
});
},
@@ -63,14 +60,14 @@ const favoriteReq = {
* @return { Promise<{json: any, params}> }
*/
deleteFavorite(params) {
return window.API.call(`favorites/${params.objectId}`, {
return request(`favorites/${params.objectId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('FAVORITE:DELETE', args);
useFavoriteStore().handleFavoriteDelete(args);
return args;
});
},
@@ -80,7 +77,7 @@ const favoriteReq = {
* @return { Promise<{json: any, params}> }
*/
getFavoriteGroups(params) {
return window.API.call('favorite/groups', {
return request('favorite/groups', {
method: 'GET',
params
}).then((json) => {
@@ -88,7 +85,6 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:GROUP:LIST', args);
return args;
});
},
@@ -99,8 +95,8 @@ const favoriteReq = {
* @return { Promise<{json: any, params}> }
*/
saveFavoriteGroup(params) {
return window.API.call(
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
return request(
`favorite/group/${params.type}/${params.group}/${getCurrentUserId()}`,
{
method: 'PUT',
params
@@ -110,7 +106,6 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:GROUP:SAVE', args);
return args;
});
},
@@ -123,8 +118,8 @@ const favoriteReq = {
* @return { Promise<{json: any, params}> }
*/
clearFavoriteGroup(params) {
return window.API.call(
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
return request(
`favorite/group/${params.type}/${params.group}/${getCurrentUserId()}`,
{
method: 'DELETE',
params
@@ -134,20 +129,16 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:GROUP:CLEAR', args);
useFavoriteStore().handleFavoriteGroupClear(args);
return args;
});
},
/**
* @param {{
* n: number,
* offset: number
* }} params
* @return { Promise<{json: any, params}> }
* @type {import('../types/favorite').getFavoriteWorlds}
*/
getFavoriteWorlds(params) {
return window.API.call('worlds/favorites', {
return request('worlds/favorites', {
method: 'GET',
params
}).then((json) => {
@@ -155,20 +146,15 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:WORLD:LIST', args);
return args;
});
},
/**
* @param {{
* n: number,
* offset: number
* }} params
* @return { Promise<{json: any, params}> }
* @type {import('../types/favorite').getFavoriteAvatars}
*/
getFavoriteAvatars(params) {
return window.API.call('avatars/favorites', {
return request('avatars/favorites', {
method: 'GET',
params
}).then((json) => {
@@ -176,12 +162,9 @@ const favoriteReq = {
json,
params
};
window.API.$emit('FAVORITE:AVATAR:LIST', args);
return args;
});
}
};
// #endregion
export default favoriteReq;

View File

@@ -1,13 +1,14 @@
// #region | API: Friend
import { request } from '../service/request';
import { useUserStore } from '../stores/user';
const friendReq = {
/**
* Fetch friends of current user.
* @param {{ n: number, offset: number, offline: boolean }} params
* @returns {Promise<{json: any, params}>}
* @type {import('../types/friend').getFriends}
*/
getFriends(params) {
return window.API.call('auth/user/friends', {
const userStore = useUserStore();
return request('auth/user/friends', {
method: 'GET',
params
}).then((json) => {
@@ -15,7 +16,13 @@ const friendReq = {
json,
params
};
window.API.$emit('FRIEND:LIST', args);
for (const user of args.json) {
if (!user.displayName) {
console.error('/friends gave us garbage', user);
continue;
}
userStore.applyUser(user);
}
return args;
});
},
@@ -25,14 +32,13 @@ const friendReq = {
* @returns {Promise<{json: T, params}>}
*/
sendFriendRequest(params) {
return window.API.call(`user/${params.userId}/friendRequest`, {
return request(`user/${params.userId}/friendRequest`, {
method: 'POST'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('FRIEND:REQUEST', args);
return args;
});
},
@@ -42,14 +48,13 @@ const friendReq = {
* @returns {Promise<{json: any, params}>}
*/
cancelFriendRequest(params) {
return window.API.call(`user/${params.userId}/friendRequest`, {
return request(`user/${params.userId}/friendRequest`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('FRIEND:REQUEST:CANCEL', args);
return args;
});
},
@@ -59,14 +64,13 @@ const friendReq = {
* @returns {Promise<{json: any, params}>}
*/
deleteFriend(params) {
return window.API.call(`auth/user/friends/${params.userId}`, {
return request(`auth/user/friends/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('FRIEND:DELETE', args);
return args;
});
},
@@ -76,7 +80,7 @@ const friendReq = {
* @returns {Promise<{json: any, params}>}
*/
getFriendStatus(params) {
return window.API.call(`user/${params.userId}/friendStatus`, {
return request(`user/${params.userId}/friendStatus`, {
method: 'GET'
}).then((json) => {
console.log('getFriendStatus', json);
@@ -84,15 +88,12 @@ const friendReq = {
json,
params
};
window.API.$emit('FRIEND:STATUS', args);
return args;
});
},
// ------------------- need to test -------------------
deleteHiddenFriendRequest(params, userId) {
return window.API.call(`user/${userId}/friendRequest`, {
return request(`user/${userId}/friendRequest`, {
method: 'DELETE',
params
}).then((json) => {
@@ -101,11 +102,9 @@ const friendReq = {
params,
userId
};
window.API.$emit('NOTIFICATION:HIDE', args);
return args;
});
}
};
// #endregion
export default friendReq;

View File

@@ -1,3 +1,9 @@
import { request } from '../service/request';
import { useUserStore, useGroupStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const groupReq = {
/**
* @param {string} groupId
@@ -5,7 +11,7 @@ const groupReq = {
* @returns
*/
setGroupRepresentation(groupId, params) {
return window.API.call(`groups/${groupId}/representation`, {
return request(`groups/${groupId}/representation`, {
method: 'PUT',
params
}).then((json) => {
@@ -23,7 +29,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
cancelGroupRequest(params) {
return window.API.call(`groups/${params.groupId}/requests`, {
return request(`groups/${params.groupId}/requests`, {
method: 'DELETE'
}).then((json) => {
const args = {
@@ -39,12 +45,9 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
deleteGroupPost(params) {
return window.API.call(
`groups/${params.groupId}/posts/${params.postId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/posts/${params.postId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
@@ -53,10 +56,10 @@ const groupReq = {
});
},
/**
* @param {{ groupId: string }} params
* @type {import('../types/group').getGroup}
*/
getGroup(params) {
return window.API.call(`groups/${params.groupId}`, {
return request(`groups/${params.groupId}`, {
method: 'GET',
params: {
includeRoles: params.includeRoles || false
@@ -66,23 +69,48 @@ const groupReq = {
json,
params
};
window.API.$emit('GROUP', args);
return args;
});
},
/**
*
* @param {{ groupId: string }} params
* @return { Promise<{json: any, params}> }
*/
getCachedGroup(params) {
const groupStore = useGroupStore();
return new Promise((resolve, reject) => {
const ref = groupStore.cachedGroups.get(params.groupId);
if (typeof ref === 'undefined') {
groupReq
.getGroup(params)
.catch(reject)
.then((args) => {
args.ref = groupStore.applyGroup(args.json);
resolve(args);
});
} else {
resolve({
cache: true,
json: ref,
params,
ref
});
}
});
},
/**
* @param {{ userId: string }} params
* @return { Promise<{json: any, params}> }
*/
getRepresentedGroup(params) {
return window.API.call(`users/${params.userId}/groups/represented`, {
return request(`users/${params.userId}/groups/represented`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('GROUP:REPRESENTED', args);
return args;
});
},
@@ -91,14 +119,13 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroups(params) {
return window.API.call(`users/${params.userId}/groups`, {
return request(`users/${params.userId}/groups`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('GROUP:LIST', args);
return args;
});
},
@@ -107,14 +134,13 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
joinGroup(params) {
return window.API.call(`groups/${params.groupId}/join`, {
return request(`groups/${params.groupId}/join`, {
method: 'POST'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('GROUP:JOIN', args);
return args;
});
},
@@ -123,7 +149,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
leaveGroup(params) {
return window.API.call(`groups/${params.groupId}/leave`, {
return request(`groups/${params.groupId}/leave`, {
method: 'POST'
}).then((json) => {
const args = {
@@ -138,7 +164,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
groupStrictsearch(params) {
return window.API.call(`groups/strictsearch`, {
return request(`groups/strictsearch`, {
method: 'GET',
params
}).then((json) => {
@@ -159,7 +185,7 @@ const groupReq = {
}
*/
setGroupMemberProps(userId, groupId, params) {
return window.API.call(`groups/${groupId}/members/${userId}`, {
return request(`groups/${groupId}/members/${userId}`, {
method: 'PUT',
params
}).then((json) => {
@@ -169,7 +195,6 @@ const groupReq = {
groupId,
params
};
window.API.$emit('GROUP:MEMBER:PROPS', args);
return args;
});
},
@@ -182,7 +207,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
addGroupMemberRole(params) {
return window.API.call(
return request(
`groups/${params.groupId}/members/${params.userId}/roles/${params.roleId}`,
{
method: 'PUT'
@@ -192,7 +217,6 @@ const groupReq = {
json,
params
};
// window.API.$emit('GROUP:MEMBER:ROLE:CHANGE', args);
return args;
});
},
@@ -205,7 +229,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
removeGroupMemberRole(params) {
return window.API.call(
return request(
`groups/${params.groupId}/members/${params.userId}/roles/${params.roleId}`,
{
method: 'DELETE'
@@ -215,19 +239,17 @@ const groupReq = {
json,
params
};
// window.API.$emit('GROUP:MEMBER:ROLE:CHANGE', args);
return args;
});
},
getGroupPermissions(params) {
return window.API.call(`users/${params.userId}/groups/permissions`, {
return request(`users/${params.userId}/groups/permissions`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('GROUP:PERMISSIONS', args);
return args;
});
},
@@ -240,7 +262,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupPosts(params) {
return window.API.call(`groups/${params.groupId}/posts`, {
return request(`groups/${params.groupId}/posts`, {
method: 'GET',
params
}).then((json) => {
@@ -248,28 +270,23 @@ const groupReq = {
json,
params
};
window.API.$emit('GROUP:POSTS', args);
return args;
});
},
editGroupPost(params) {
return window.API.call(
`groups/${params.groupId}/posts/${params.postId}`,
{
method: 'PUT',
params
}
).then((json) => {
return request(`groups/${params.groupId}/posts/${params.postId}`, {
method: 'PUT',
params
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('GROUP:POST', args);
return args;
});
},
createGroupPost(params) {
return window.API.call(`groups/${params.groupId}/posts`, {
return request(`groups/${params.groupId}/posts`, {
method: 'POST',
params
}).then((json) => {
@@ -277,7 +294,6 @@ const groupReq = {
json,
params
};
window.API.$emit('GROUP:POST', args);
return args;
});
},
@@ -289,17 +305,13 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupMember(params) {
return window.API.call(
`groups/${params.groupId}/members/${params.userId}`,
{
method: 'GET'
}
).then((json) => {
return request(`groups/${params.groupId}/members/${params.userId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('GROUP:MEMBER', args);
return args;
});
},
@@ -312,7 +324,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupMembers(params) {
return window.API.call(`groups/${params.groupId}/members`, {
return request(`groups/${params.groupId}/members`, {
method: 'GET',
params
}).then((json) => {
@@ -320,7 +332,6 @@ const groupReq = {
json,
params
};
window.API.$emit('GROUP:MEMBERS', args);
return args;
});
},
@@ -334,7 +345,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupMembersSearch(params) {
return window.API.call(`groups/${params.groupId}/members/search`, {
return request(`groups/${params.groupId}/members/search`, {
method: 'GET',
params
}).then((json) => {
@@ -352,7 +363,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
blockGroup(params) {
return window.API.call(`groups/${params.groupId}/block`, {
return request(`groups/${params.groupId}/block`, {
method: 'POST'
}).then((json) => {
const args = {
@@ -370,12 +381,9 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
unblockGroup(params) {
return window.API.call(
`groups/${params.groupId}/members/${params.userId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/members/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
@@ -391,7 +399,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
sendGroupInvite(params) {
return window.API.call(`groups/${params.groupId}/invites`, {
return request(`groups/${params.groupId}/invites`, {
method: 'POST',
params: {
userId: params.userId
@@ -401,7 +409,6 @@ const groupReq = {
json,
params
};
window.API.$emit('GROUP:INVITE', args);
return args;
});
},
@@ -413,18 +420,13 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
kickGroupMember(params) {
return window.API.call(
`groups/${params.groupId}/members/${params.userId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/members/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:MEMBER:KICK', args);
return args;
});
},
@@ -433,7 +435,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
banGroupMember(params) {
return window.API.call(`groups/${params.groupId}/bans`, {
return request(`groups/${params.groupId}/bans`, {
method: 'POST',
params: {
userId: params.userId
@@ -443,24 +445,17 @@ const groupReq = {
json,
params
};
// useless code
// window.API.$emit('GROUP:MEMBER:BAN', args);
return args;
});
},
unbanGroupMember(params) {
return window.API.call(
`groups/${params.groupId}/bans/${params.userId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/bans/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:MEMBER:UNBAN', args);
return args;
});
},
@@ -469,97 +464,73 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
deleteSentGroupInvite(params) {
return window.API.call(
`groups/${params.groupId}/invites/${params.userId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/invites/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:INVITE:DELETE', args);
return args;
});
},
deleteBlockedGroupRequest(params) {
return window.API.call(
`groups/${params.groupId}/members/${params.userId}`,
{
method: 'DELETE'
}
).then((json) => {
return request(`groups/${params.groupId}/members/${params.userId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:BLOCKED:DELETE', args);
return args;
});
},
acceptGroupInviteRequest(params) {
return window.API.call(
`groups/${params.groupId}/requests/${params.userId}`,
{
method: 'PUT',
params: {
action: 'accept'
}
return request(`groups/${params.groupId}/requests/${params.userId}`, {
method: 'PUT',
params: {
action: 'accept'
}
).then((json) => {
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:INVITE:ACCEPT', args);
return args;
});
},
rejectGroupInviteRequest(params) {
return window.API.call(
`groups/${params.groupId}/requests/${params.userId}`,
{
method: 'PUT',
params: {
action: 'reject'
}
return request(`groups/${params.groupId}/requests/${params.userId}`, {
method: 'PUT',
params: {
action: 'reject'
}
).then((json) => {
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:INVITE:REJECT', args);
return args;
});
},
blockGroupInviteRequest(params) {
return window.API.call(
`groups/${params.groupId}/requests/${params.userId}`,
{
method: 'PUT',
params: {
action: 'reject',
block: true
}
return request(`groups/${params.groupId}/requests/${params.userId}`, {
method: 'PUT',
params: {
action: 'reject',
block: true
}
).then((json) => {
}).then((json) => {
const args = {
json,
params
};
// useless code
// window.API.$emit('GROUP:INVITE:BLOCK', args);
return args;
});
},
getGroupBans(params) {
return window.API.call(`groups/${params.groupId}/bans`, {
return request(`groups/${params.groupId}/bans`, {
method: 'GET',
params
}).then((json) => {
@@ -575,7 +546,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupAuditLogTypes(params) {
return window.API.call(`groups/${params.groupId}/auditLogTypes`, {
return request(`groups/${params.groupId}/auditLogTypes`, {
method: 'GET'
}).then((json) => {
const args = {
@@ -590,7 +561,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupLogs(params) {
return window.API.call(`groups/${params.groupId}/auditLogs`, {
return request(`groups/${params.groupId}/auditLogs`, {
method: 'GET',
params
}).then((json) => {
@@ -606,7 +577,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupInvites(params) {
return window.API.call(`groups/${params.groupId}/invites`, {
return request(`groups/${params.groupId}/invites`, {
method: 'GET',
params
}).then((json) => {
@@ -622,7 +593,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupJoinRequests(params) {
return window.API.call(`groups/${params.groupId}/requests`, {
return request(`groups/${params.groupId}/requests`, {
method: 'GET',
params
}).then((json) => {
@@ -630,7 +601,6 @@ const groupReq = {
json,
params
};
// window.API.$emit('GROUP:JOINREQUESTS', args);
return args;
});
},
@@ -639,8 +609,8 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupInstances(params) {
return window.API.call(
`users/${window.API.currentUser.id}/instances/groups/${params.groupId}`,
return request(
`users/${getCurrentUserId()}/instances/groups/${params.groupId}`,
{
method: 'GET'
}
@@ -657,7 +627,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupRoles(params) {
return window.API.call(`groups/${params.groupId}/roles`, {
return request(`groups/${params.groupId}/roles`, {
method: 'GET',
params
}).then((json) => {
@@ -665,22 +635,16 @@ const groupReq = {
json,
params
};
// useless code
// this.$emit('GROUP:ROLES', args);
return args;
});
},
getUsersGroupInstances() {
return window.API.call(
`users/${window.API.currentUser.id}/instances/groups`,
{
method: 'GET'
}
).then((json) => {
return request(`users/${getCurrentUserId()}/instances/groups`, {
method: 'GET'
}).then((json) => {
const args = {
json
};
window.API.$emit('GROUP:USER:INSTANCES', args);
return args;
});
},
@@ -696,7 +660,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
groupSearch(params) {
return window.API.call(`groups`, {
return request(`groups`, {
method: 'GET',
params
}).then((json) => {
@@ -717,7 +681,7 @@ const groupReq = {
* @return { Promise<{json: any, params}> }
*/
getGroupGallery(params) {
return window.API.call(
return request(
`groups/${params.groupId}/galleries/${params.galleryId}`,
{
method: 'GET',
@@ -735,10 +699,9 @@ const groupReq = {
});
}
// no place to use this
// getRequestedGroups() {
// return window.API.call(
// `users/${window.API.currentUser.id}/groups/requested`,
// return request(
// `users/${API.currentUser.id}/groups/requested`,
// {
// method: 'GET'
// }
@@ -746,18 +709,17 @@ const groupReq = {
// const args = {
// json
// };
// window.API.$emit('GROUP:REQUESTED', args);
// API.$emit('GROUP:REQUESTED', args);
// return args;
// });
// }
// ----------------- left over code -----------------
// /**
// * @param {{ groupId: string }} params
// * @return { Promise<{json: any, params}> }
// */
// API.getGroupAnnouncement = function (params) {
// return this.call(`groups/${params.groupId}/announcement`, {
// return request(`groups/${params.groupId}/announcement`, {
// method: 'GET'
// }).then((json) => {
// var args = {

View File

@@ -1,25 +1,26 @@
import { request } from '../service/request';
import { useAvatarStore, useWorldStore } from '../stores';
const imageReq = {
// use in uploadAvatarImage
// need to test
async uploadAvatarFailCleanup(id) {
const json = await window.API.call(`file/${id}`, {
const avatarStore = useAvatarStore();
const json = await request(`file/${id}`, {
method: 'GET'
});
const fileId = json.id;
const fileVersion = json.versions[json.versions.length - 1].version;
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
request(`file/${fileId}/${fileVersion}/signature/finish`, {
method: 'PUT'
});
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
request(`file/${fileId}/${fileVersion}/file/finish`, {
method: 'PUT'
});
window.$app.avatarDialog.loading = false;
// window.$app.changeAvatarImageDialogLoading = false;
avatarStore.avatarDialog.loading = false;
},
async uploadAvatarImage(params, fileId) {
try {
return await window.API.call(`file/${fileId}`, {
return await request(`file/${fileId}`, {
method: 'POST',
params
}).then((json) => {
@@ -28,7 +29,6 @@ const imageReq = {
params,
fileId
};
// window.API.$emit('AVATARIMAGE:INIT', args);
return args;
});
} catch (err) {
@@ -36,12 +36,11 @@ const imageReq = {
imageReq.uploadAvatarFailCleanup(fileId);
throw err;
}
// return void 0;
},
async uploadAvatarImageFileStart(params) {
try {
return await window.API.call(
return await request(
`file/${params.fileId}/${params.fileVersion}/file/start`,
{
method: 'PUT'
@@ -51,18 +50,16 @@ const imageReq = {
json,
params
};
// window.API.$emit('AVATARIMAGE:FILESTART', args);
return args;
});
} catch (err) {
console.error(err);
imageReq.uploadAvatarFailCleanup(params.fileId);
}
return void 0;
},
uploadAvatarImageFileFinish(params) {
return window.API.call(
return request(
`file/${params.fileId}/${params.fileVersion}/file/finish`,
{
method: 'PUT',
@@ -76,14 +73,13 @@ const imageReq = {
json,
params
};
// window.API.$emit('AVATARIMAGE:FILEFINISH', args);
return args;
});
},
async uploadAvatarImageSigStart(params) {
try {
return await window.API.call(
return await request(
`file/${params.fileId}/${params.fileVersion}/signature/start`,
{
method: 'PUT'
@@ -93,18 +89,16 @@ const imageReq = {
json,
params
};
// window.API.$emit('AVATARIMAGE:SIGSTART', args);
return args;
});
} catch (err) {
console.error(err);
imageReq.uploadAvatarFailCleanup(params.fileId);
}
return void 0;
},
uploadAvatarImageSigFinish(params) {
return window.API.call(
return request(
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
{
method: 'PUT',
@@ -118,13 +112,12 @@ const imageReq = {
json,
params
};
// window.API.$emit('AVATARIMAGE:SIGFINISH', args);
return args;
});
},
setAvatarImage(params) {
return window.API.call(`avatars/${params.id}`, {
return request(`avatars/${params.id}`, {
method: 'PUT',
params
}).then((json) => {
@@ -132,33 +125,29 @@ const imageReq = {
json,
params
};
// window.API.$emit('AVATARIMAGE:SET', args);
window.API.$emit('AVATAR', args);
return args;
});
},
// use in uploadWorldImage
// need to test
async uploadWorldFailCleanup(id) {
const json = await window.API.call(`file/${id}`, {
const worldStore = useWorldStore();
const json = await request(`file/${id}`, {
method: 'GET'
});
const fileId = json.id;
const fileVersion = json.versions[json.versions.length - 1].version;
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
request(`file/${fileId}/${fileVersion}/signature/finish`, {
method: 'PUT'
});
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
request(`file/${fileId}/${fileVersion}/file/finish`, {
method: 'PUT'
});
window.$app.worldDialog.loading = false;
// window.$app.changeWorldImageDialogLoading = false;
worldStore.worldDialog.loading = false;
},
async uploadWorldImage(params, fileId) {
try {
return await window.API.call(`file/${fileId}`, {
return await request(`file/${fileId}`, {
method: 'POST',
params
}).then((json) => {
@@ -167,7 +156,6 @@ const imageReq = {
params,
fileId
};
// window.API.$emit('WORLDIMAGE:INIT', args);
return args;
});
} catch (err) {
@@ -179,7 +167,7 @@ const imageReq = {
async uploadWorldImageFileStart(params) {
try {
return await window.API.call(
return await request(
`file/${params.fileId}/${params.fileVersion}/file/start`,
{
method: 'PUT'
@@ -189,7 +177,6 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:FILESTART', args);
return args;
});
} catch (err) {
@@ -200,7 +187,7 @@ const imageReq = {
},
uploadWorldImageFileFinish(params) {
return window.API.call(
return request(
`file/${params.fileId}/${params.fileVersion}/file/finish`,
{
method: 'PUT',
@@ -214,14 +201,13 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:FILEFINISH', args);
return args;
});
},
async uploadWorldImageSigStart(params) {
try {
return await window.API.call(
return await request(
`file/${params.fileId}/${params.fileVersion}/signature/start`,
{
method: 'PUT'
@@ -231,7 +217,6 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:SIGSTART', args);
return args;
});
} catch (err) {
@@ -242,7 +227,7 @@ const imageReq = {
},
uploadWorldImageSigFinish(params) {
return window.API.call(
return request(
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
{
method: 'PUT',
@@ -256,13 +241,13 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:SIGFINISH', args);
return args;
});
},
setWorldImage(params) {
return window.API.call(`worlds/${params.id}`, {
const worldStore = useWorldStore();
return request(`worlds/${params.id}`, {
method: 'PUT',
params
}).then((json) => {
@@ -270,27 +255,25 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:SET', args);
window.API.$emit('WORLD', args);
args.ref = worldStore.applyWorld(json);
return args;
});
},
getAvatarImages(params) {
return window.API.call(`file/${params.fileId}`, {
return request(`file/${params.fileId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('AVATARIMAGE:GET', args);
return args;
});
},
getWorldImages(params) {
return window.API.call(`file/${params.fileId}`, {
return request(`file/${params.fileId}`, {
method: 'GET',
params
}).then((json) => {
@@ -298,7 +281,6 @@ const imageReq = {
json,
params
};
// window.API.$emit('WORLDIMAGE:GET', args);
return args;
});
}

View File

@@ -1,9 +1,6 @@
/**
* API requests
* Export all API requests from here
*
* "window.API" is used as app.js is a large IIFE, preventing direct API export. No current issues
* Refactoring may be required
*/
import userRequest from './user';
@@ -21,6 +18,7 @@ import inviteMessagesRequest from './inviteMessages';
import imageRequest from './image';
import miscRequest from './misc';
import groupRequest from './group';
import authRequest from './auth';
import inventoryRequest from './inventory';
import propRequest from './prop';
@@ -39,6 +37,7 @@ window.request = {
inviteMessagesRequest,
imageRequest,
miscRequest,
authRequest,
groupRequest,
inventoryRequest,
propRequest
@@ -59,6 +58,7 @@ export {
inviteMessagesRequest,
imageRequest,
miscRequest,
authRequest,
groupRequest,
inventoryRequest,
propRequest

View File

@@ -1,22 +1,22 @@
// #region | API: Instance
import { $app } from '../app';
import { t } from '../plugin';
import { request } from '../service/request';
import { useInstanceStore } from '../stores';
const instanceReq = {
/**
* @param {{worldId: string, instanceId: string}} params
* @returns {Promise<{json: any, params}>}
* @type {import('../types/instance').getInstance}
*/
getInstance(params) {
return window.API.call(
`instances/${params.worldId}:${params.instanceId}`,
{
method: 'GET'
}
).then((json) => {
const instanceStore = useInstanceStore();
return request(`instances/${params.worldId}:${params.instanceId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('INSTANCE', args);
args.ref = instanceStore.applyInstance(json);
return args;
});
},
@@ -37,7 +37,8 @@ const instanceReq = {
* @returns {Promise<{json: any, params}>}
*/
createInstance(params) {
return window.API.call('instances', {
const instanceStore = useInstanceStore();
return request('instances', {
method: 'POST',
params
}).then((json) => {
@@ -45,7 +46,7 @@ const instanceReq = {
json,
params
};
window.API.$emit('INSTANCE', args);
args.ref = instanceStore.applyInstance(json);
return args;
});
},
@@ -59,7 +60,7 @@ const instanceReq = {
if (instance.shortName) {
params.shortName = instance.shortName;
}
return window.API.call(
return request(
`instances/${instance.worldId}:${instance.instanceId}/shortName`,
{
method: 'GET',
@@ -80,14 +81,15 @@ const instanceReq = {
* @returns {Promise<{json: any, params}>}
*/
getInstanceFromShortName(params) {
return window.API.call(`instances/s/${params.shortName}`, {
const instanceStore = useInstanceStore();
return request(`instances/s/${params.shortName}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('INSTANCE', args);
args.ref = instanceStore.applyInstance(json);
return args;
});
},
@@ -105,7 +107,7 @@ const instanceReq = {
if (instance.shortName) {
params.shortName = instance.shortName;
}
return window.API.call(
return request(
`invite/myself/to/${instance.worldId}:${instance.instanceId}`,
{
method: 'POST',
@@ -121,20 +123,19 @@ const instanceReq = {
})
.catch((err) => {
if (err?.error?.message) {
window.$app.$message({
$app.$message({
message: err.error.message,
type: 'error'
});
throw err;
}
window.$app.$message({
message: window.$t('message.instance.not_allowed'),
$app.$message({
message: t('message.instance.not_allowed'),
type: 'error'
});
throw err;
});
}
};
// #endregion
export default instanceReq;

View File

@@ -1,10 +1,12 @@
import { request } from '../service/request';
const inventoryReq = {
/**
* @param {{ inventoryId: string, userId: string }} params
* @returns {Promise<{json: any, params}>}
*/
getUserInventoryItem(params) {
return window.API.call(
return request(
`user/${params.userId}/inventory/${params.inventoryId}`,
{
method: 'GET'
@@ -23,7 +25,7 @@ const inventoryReq = {
* @returns {Promise<{json: any, params}>}
*/
getInventoryItem(params) {
return window.API.call(`inventory/${params.inventoryId}`, {
return request(`inventory/${params.inventoryId}`, {
method: 'GET',
params
}).then((json) => {
@@ -40,7 +42,7 @@ const inventoryReq = {
* @returns {Promise<{json: any, params}>}
*/
getInventoryItems(params) {
return window.API.call('inventory', {
return request('inventory', {
method: 'GET',
params
}).then((json) => {
@@ -57,7 +59,7 @@ const inventoryReq = {
* @returns {Promise<{json: any, params}>}
*/
consumeInventoryBundle(params) {
return window.API.call(`inventory/${params.inventoryId}/consume`, {
return request(`inventory/${params.inventoryId}/consume`, {
method: 'PUT',
params
}).then((json) => {
@@ -74,13 +76,10 @@ const inventoryReq = {
* @returns {Promise<{json: any, params}>}
*/
getInventoryTemplate(params) {
return window.API.call(
`inventory/template/${params.inventoryTemplateId}`,
{
method: 'GET',
params
}
).then((json) => {
return request(`inventory/template/${params.inventoryTemplateId}`, {
method: 'GET',
params
}).then((json) => {
const args = {
json,
params

View File

@@ -1,30 +1,28 @@
// #region | App: Invite Messages
import { request } from '../service/request';
import { useUserStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const inviteMessagesReq = {
refreshInviteMessageTableData(messageType) {
return window.API.call(
`message/${window.API.currentUser.id}/${messageType}`,
{
method: 'GET'
}
).then((json) => {
return request(`message/${getCurrentUserId()}/${messageType}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
messageType
};
window.API.$emit(`INVITE:${messageType.toUpperCase()}`, args);
return args;
});
},
editInviteMessage(params, messageType, slot) {
return window.API.call(
`message/${window.API.currentUser.id}/${messageType}/${slot}`,
{
method: 'PUT',
params
}
).then((json) => {
return request(`message/${getCurrentUserId()}/${messageType}/${slot}`, {
method: 'PUT',
params
}).then((json) => {
const args = {
json,
params,
@@ -36,6 +34,4 @@ const inviteMessagesReq = {
}
};
// #endregion
export default inviteMessagesReq;

View File

@@ -1,6 +1,13 @@
import { request } from '../service/request';
import { useUserStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const miscReq = {
getBundles(fileId) {
return window.API.call(`file/${fileId}`, {
return request(`file/${fileId}`, {
method: 'GET'
}).then((json) => {
const args = {
@@ -11,7 +18,7 @@ const miscReq = {
},
saveNote(params) {
return window.API.call('userNotes', {
return request('userNotes', {
method: 'POST',
params
}).then((json) => {
@@ -19,7 +26,6 @@ const miscReq = {
json,
params
};
// window.API.$emit('NOTE', args);
return args;
});
},
@@ -34,7 +40,7 @@ const miscReq = {
* @return { Promise<{json: any, params}> }
*/
reportUser(params) {
return window.API.call(`feedback/${params.userId}/user`, {
return request(`feedback/${params.userId}/user`, {
method: 'POST',
params: {
contentType: params.contentType,
@@ -46,7 +52,6 @@ const miscReq = {
json,
params
};
// window.API.$emit('FEEDBACK:REPORT:USER', args);
return args;
});
},
@@ -59,7 +64,7 @@ const miscReq = {
* @return { Promise<{json: any, params}> }
*/
getFileAnalysis(params) {
return window.API.call(
return request(
`analysis/${params.fileId}/${params.version}/${params.variant}`,
{
method: 'GET'
@@ -69,19 +74,17 @@ const miscReq = {
json,
params
};
// window.API.$emit('FILE:ANALYSIS', args);
return args;
});
},
getVRChatCredits() {
return window.API.call(`user/${window.API.currentUser.id}/balance`, {
return request(`user/${getCurrentUserId()}/balance`, {
method: 'GET'
}).then((json) => {
const args = {
json
};
// window.API.$emit('VRCCREDITS', args);
return args;
});
},
@@ -94,7 +97,7 @@ const miscReq = {
* @returns {Promise<{json: any, params}>}
*/
closeInstance(params) {
return window.API.call(`instances/${params.location}`, {
return request(`instances/${params.location}`, {
method: 'DELETE',
params: {
hardClose: params.hardClose ?? false
@@ -104,7 +107,6 @@ const miscReq = {
json,
params
};
window.API.$emit('INSTANCE:CLOSE', args);
return args;
});
},
@@ -116,8 +118,8 @@ const miscReq = {
* @returns {Promise<{json: any, params}>}
*/
deleteWorldPersistData(params) {
return window.API.call(
`users/${window.API.currentUser.id}/${params.worldId}/persist`,
return request(
`users/${getCurrentUserId()}/${params.worldId}/persist`,
{
method: 'DELETE'
}
@@ -126,7 +128,6 @@ const miscReq = {
json,
params
};
window.API.$emit('WORLD:PERSIST:DELETE', args);
return args;
});
},
@@ -138,8 +139,8 @@ const miscReq = {
* @returns {Promise<{json: any, params}>}
*/
hasWorldPersistData(params) {
return window.API.call(
`users/${window.API.currentUser.id}/${params.worldId}/persist/exists`,
return request(
`users/${getCurrentUserId()}/${params.worldId}/persist/exists`,
{
method: 'GET'
}
@@ -148,47 +149,41 @@ const miscReq = {
json,
params
};
window.API.$emit('WORLD:PERSIST:HAS', args);
return args;
});
},
updateBadge(params) {
return window.API.call(
`users/${window.API.currentUser.id}/badges/${params.badgeId}`,
{
method: 'PUT',
params: {
userId: window.API.currentUser.id,
badgeId: params.badgeId,
hidden: params.hidden,
showcased: params.showcased
}
return request(`users/${getCurrentUserId()}/badges/${params.badgeId}`, {
method: 'PUT',
params: {
userId: getCurrentUserId(),
badgeId: params.badgeId,
hidden: params.hidden,
showcased: params.showcased
}
).then((json) => {
}).then((json) => {
const args = {
json,
params
};
// window.API.$emit('BADGE:UPDATE', args);
return args;
});
},
getVisits() {
return window.API.call('visits', {
return request('visits', {
method: 'GET'
}).then((json) => {
const args = {
json
};
// window.API.$emit('VISITS', args);
return args;
});
},
deleteFile(fileId) {
return window.API.call(`file/${fileId}`, {
return request(`file/${fileId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
@@ -207,7 +202,7 @@ const miscReq = {
// * @returns {Promise<{json: any, params}>}
// */
// sendBoop(params) {
// return window.API.call(`users/${params.userId}/boop`, {
// return request(`users/${params.userId}/boop`, {
// method: 'POST',
// params
// }).then((json) => {

View File

@@ -1,4 +1,9 @@
// #region | API: Notification
import { request } from '../service/request';
import { useGroupStore, useNotificationStore } from '../stores';
function getGalleryStore() {
return useGroupStore();
}
const notificationReq = {
/** @typedef {{
@@ -17,7 +22,7 @@ const notificationReq = {
* @returns {Promise<{json: any, params}>}
*/
getNotifications(params) {
return window.API.call('auth/user/notifications', {
return request('auth/user/notifications', {
method: 'GET',
params
}).then((json) => {
@@ -25,13 +30,13 @@ const notificationReq = {
json,
params
};
window.API.$emit('NOTIFICATION:LIST', args);
return args;
});
},
getHiddenFriendRequests(params) {
return window.API.call('auth/user/notifications', {
return request('auth/user/notifications', {
method: 'GET',
params: {
type: 'friendRequest',
@@ -43,13 +48,12 @@ const notificationReq = {
json,
params
};
window.API.$emit('NOTIFICATION:LIST:HIDDEN', args);
return args;
});
},
getNotificationsV2(params) {
return window.API.call('notifications', {
return request('notifications', {
method: 'GET',
params
}).then((json) => {
@@ -57,7 +61,6 @@ const notificationReq = {
json,
params
};
window.API.$emit('NOTIFICATION:V2:LIST', args);
return args;
});
},
@@ -80,7 +83,7 @@ const notificationReq = {
* @return { Promise<{json: any, params}> }
*/
sendInvite(params, receiverUserId) {
return window.API.call(`invite/${receiverUserId}`, {
return request(`invite/${receiverUserId}`, {
method: 'POST',
params
}).then((json) => {
@@ -89,28 +92,26 @@ const notificationReq = {
params,
receiverUserId
};
window.API.$emit('NOTIFICATION:INVITE:SEND', args);
return args;
});
},
sendInvitePhoto(params, receiverUserId) {
return window.API.call(`invite/${receiverUserId}/photo`, {
return request(`invite/${receiverUserId}/photo`, {
uploadImageLegacy: true,
postData: JSON.stringify(params),
imageData: window.$app.uploadImage
imageData: getGalleryStore().uploadImage
}).then((json) => {
const args = {
json,
params,
receiverUserId
};
window.API.$emit('NOTIFICATION:INVITE:PHOTO:SEND', args);
return args;
});
},
sendRequestInvite(params, receiverUserId) {
return window.API.call(`requestInvite/${receiverUserId}`, {
return request(`requestInvite/${receiverUserId}`, {
method: 'POST',
params
}).then((json) => {
@@ -119,29 +120,27 @@ const notificationReq = {
params,
receiverUserId
};
window.API.$emit('NOTIFICATION:REQUESTINVITE:SEND', args);
return args;
});
},
sendRequestInvitePhoto(params, receiverUserId) {
return window.API.call(`requestInvite/${receiverUserId}/photo`, {
return request(`requestInvite/${receiverUserId}/photo`, {
uploadImageLegacy: true,
postData: JSON.stringify(params),
imageData: window.$app.uploadImage
imageData: getGalleryStore().uploadImage
}).then((json) => {
const args = {
json,
params,
receiverUserId
};
window.API.$emit('NOTIFICATION:REQUESTINVITE:PHOTO:SEND', args);
return args;
});
},
sendInviteResponse(params, inviteId) {
return window.API.call(`invite/${inviteId}/response`, {
return request(`invite/${inviteId}/response`, {
method: 'POST',
params,
inviteId
@@ -151,16 +150,15 @@ const notificationReq = {
params,
inviteId
};
window.API.$emit('INVITE:RESPONSE:SEND', args);
return args;
});
},
sendInviteResponsePhoto(params, inviteId) {
return window.API.call(`invite/${inviteId}/response/photo`, {
return request(`invite/${inviteId}/response/photo`, {
uploadImageLegacy: true,
postData: JSON.stringify(params),
imageData: window.$app.uploadImage,
imageData: getGalleryStore().uploadImage,
inviteId
}).then((json) => {
const args = {
@@ -168,7 +166,6 @@ const notificationReq = {
params,
inviteId
};
window.API.$emit('INVITE:RESPONSE:PHOTO:SEND', args);
return args;
});
},
@@ -178,7 +175,7 @@ const notificationReq = {
* @return { Promise<{json: any, params}> }
*/
acceptFriendRequestNotification(params) {
return window.API.call(
return request(
`auth/user/notifications/${params.notificationId}/accept`,
{
method: 'PUT'
@@ -189,13 +186,13 @@ const notificationReq = {
json,
params
};
window.API.$emit('NOTIFICATION:ACCEPT', args);
useNotificationStore().handleNotificationAccept(args);
return args;
})
.catch((err) => {
// if friend request could not be found, delete it
if (err && err.message && err.message.includes('404')) {
window.API.$emit('NOTIFICATION:HIDE', { params });
useNotificationStore().handleNotificationHide({ params });
}
});
},
@@ -205,7 +202,7 @@ const notificationReq = {
* @return { Promise<{json: any, params}> }
*/
hideNotification(params) {
return window.API.call(
return request(
`auth/user/notifications/${params.notificationId}/hide`,
{
method: 'PUT'
@@ -215,13 +212,11 @@ const notificationReq = {
json,
params
};
window.API.$emit('NOTIFICATION:HIDE', args);
useNotificationStore().handleNotificationHide(args);
return args;
});
},
// ------------------- need to test -------------------
/**
* @param {{
* notificationId: string,
@@ -231,32 +226,14 @@ const notificationReq = {
* @return { Promise<{json: any, params}> }
*/
sendNotificationResponse(params) {
return window.API.call(
`notifications/${params.notificationId}/respond`,
{
method: 'POST',
params
}
)
.then((json) => {
const args = {
json,
params
};
window.API.$emit('NOTIFICATION:RESPONSE', args);
return args;
})
.catch((err) => {
// TODO: need to test
// something went wrong, lets assume it's already expired
window.API.$emit('NOTIFICATION:HIDE', { params });
notificationReq.hideNotificationV2(params.notificationId);
throw err;
});
return request(`notifications/${params.notificationId}/respond`, {
method: 'POST',
params
});
},
// use in sendNotificationResponse
hideNotificationV2(notificationId) {
return window.API.call(`notifications/${notificationId}`, {
return request(`notifications/${notificationId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
@@ -265,16 +242,12 @@ const notificationReq = {
notificationId
}
};
// useless
// window.API.$emit('NOTIFICATION:V2:HIDE', args);
return args;
});
}
// ------------------ look like no place use these requests ------------------
// sendInviteGalleryPhoto(params, receiverUserId) {
// return window.API.call(`invite/${receiverUserId}/photo`, {
// return request(`invite/${receiverUserId}/photo`, {
// method: 'POST',
// params
// }).then((json) => {
@@ -283,13 +256,13 @@ const notificationReq = {
// params,
// receiverUserId
// };
// window.API.$emit('NOTIFICATION:INVITE:GALLERYPHOTO:SEND', args);
// API.$emit('NOTIFICATION:INVITE:GALLERYPHOTO:SEND', args);
// return args;
// });
// },
// API.clearNotifications = function () {
// return this.call('auth/user/notifications/clear', {
// return request('auth/user/notifications/clear', {
// method: 'PUT'
// }).then((json) => {
// var args = {

View File

@@ -1,14 +1,13 @@
// #region | API: PlayerModeration
import { request } from '../service/request';
const playerModerationReq = {
getPlayerModerations() {
return window.API.call('auth/user/playermoderations', {
return request('auth/user/playermoderations', {
method: 'GET'
}).then((json) => {
const args = {
json
};
window.API.$emit('PLAYER-MODERATION:LIST', args);
return args;
});
},
@@ -19,7 +18,7 @@ const playerModerationReq = {
*/
// old-way: POST auth/user/blocks {blocked:userId}
sendPlayerModeration(params) {
return window.API.call('auth/user/playermoderations', {
return request('auth/user/playermoderations', {
method: 'POST',
params
}).then((json) => {
@@ -27,7 +26,6 @@ const playerModerationReq = {
json,
params
};
// window.API.$emit('PLAYER-MODERATION:SEND', args);
return args;
});
},
@@ -38,7 +36,7 @@ const playerModerationReq = {
*/
// old-way: PUT auth/user/unblocks {blocked:userId}
deletePlayerModeration(params) {
return window.API.call('auth/user/unplayermoderate', {
return request('auth/user/unplayermoderate', {
method: 'PUT',
params
}).then((json) => {
@@ -46,11 +44,9 @@ const playerModerationReq = {
json,
params
};
window.API.$emit('PLAYER-MODERATION:DELETE', args);
return args;
});
}
};
// #endregion
export default playerModerationReq;

View File

@@ -1,10 +1,12 @@
import { request } from '../service/request';
const propReq = {
/**
* @param {{ propId: string }} params
* @returns {Promise<{json: any, params}>}
*/
getProp(params) {
return window.API.call(`props/${params.propId}`, {
return request(`props/${params.propId}`, {
method: 'GET',
params
}).then((json) => {

View File

@@ -1,13 +1,19 @@
// #region | API: User
import { request } from '../service/request';
import { useUserStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const userReq = {
/**
* Fetch user from API.
* @param {{ userId: string }} params identifier of registered user
* @returns {Promise<{json: any, params}>}
* identifier of registered user
* @type {import('../types/user').getUser}
*/
getUser(params) {
return window.API.call(`users/${params.userId}`, {
const userStore = useUserStore();
return request(`users/${params.userId}`, {
method: 'GET'
}).then((json) => {
if (!json) {
@@ -19,7 +25,7 @@ const userReq = {
json,
params
};
window.API.$emit('USER', args);
args.ref = userStore.applyUser(json);
return args;
});
},
@@ -30,10 +36,17 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
getCachedUser(params) {
const userStore = useUserStore();
return new Promise((resolve, reject) => {
const ref = window.API.cachedUsers.get(params.userId);
const ref = userStore.cachedUsers.get(params.userId);
if (typeof ref === 'undefined') {
userReq.getUser(params).catch(reject).then(resolve);
userReq
.getUser(params)
.catch(reject)
.then((args) => {
args.ref = userStore.applyUser(args.json);
resolve(args);
});
} else {
resolve({
cache: true,
@@ -59,7 +72,7 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
getUsers(params) {
return window.API.call('users', {
return request('users', {
method: 'GET',
params
}).then((json) => {
@@ -67,7 +80,6 @@ const userReq = {
json,
params
};
window.API.$emit('USER:LIST', args);
return args;
});
},
@@ -77,7 +89,8 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
addUserTags(params) {
return window.API.call(`users/${window.API.currentUser.id}/addTags`, {
const userStore = useUserStore();
return request(`users/${getCurrentUserId()}/addTags`, {
method: 'POST',
params
}).then((json) => {
@@ -85,7 +98,7 @@ const userReq = {
json,
params
};
window.API.$emit('USER:CURRENT:SAVE', args);
userStore.applyCurrentUser(json);
return args;
});
},
@@ -95,18 +108,16 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
removeUserTags(params) {
return window.API.call(
`users/${window.API.currentUser.id}/removeTags`,
{
method: 'POST',
params
}
).then((json) => {
const userStore = useUserStore();
return request(`users/${getCurrentUserId()}/removeTags`, {
method: 'POST',
params
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('USER:CURRENT:SAVE', args);
userStore.applyCurrentUser(json);
return args;
});
},
@@ -116,7 +127,7 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
getUserFeedback(params) {
return window.API.call(`users/${params.userId}/feedback`, {
return request(`users/${params.userId}/feedback`, {
method: 'GET',
params: {
n: 100
@@ -126,7 +137,6 @@ const userReq = {
json,
params
};
// window.API.$emit('USER:FEEDBACK', args);
return args;
});
},
@@ -144,15 +154,16 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
saveCurrentUser(params) {
return window.API.call(`users/${window.API.currentUser.id}`, {
const userStore = useUserStore();
return request(`users/${getCurrentUserId()}`, {
method: 'PUT',
params
}).then((json) => {
var args = {
const args = {
json,
params
};
window.API.$emit('USER:CURRENT:SAVE', args);
userStore.applyCurrentUser(json);
return args;
});
},
@@ -162,7 +173,7 @@ const userReq = {
* @returns {Promise<{json: any, params}>}
*/
getUserNotes(params) {
return window.API.call(`userNotes`, {
return request(`userNotes`, {
method: 'GET',
params
}).then((json) => {
@@ -170,11 +181,9 @@ const userReq = {
json,
params
};
// window.API.$emit('USER:NOTES', args);
return args;
});
}
};
// #endregion
export default userReq;

View File

@@ -1,8 +1,8 @@
// #region | App: VRCPlus Icons
import { request } from '../service/request';
const VRCPlusIconsReq = {
getFileList(params) {
return window.API.call('files', {
return request('files', {
method: 'GET',
params
}).then((json) => {
@@ -10,7 +10,18 @@ const VRCPlusIconsReq = {
json,
params
};
window.API.$emit('FILES:LIST', args);
return args;
});
},
deleteFile(fileId) {
return request(`file/${fileId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
fileId
};
return args;
});
},
@@ -19,7 +30,7 @@ const VRCPlusIconsReq = {
const params = {
tag: 'icon'
};
return window.API.call('file/image', {
return request('file/image', {
uploadImage: true,
matchingDimensions: true,
postData: JSON.stringify(params),
@@ -29,15 +40,12 @@ const VRCPlusIconsReq = {
json,
params
};
window.API.$emit('VRCPLUSICON:ADD', args);
return args;
});
}
// unused
// images.pug line 63
// deleteFileVersion(params) {
// return window.API.call(`file/${params.fileId}/${params.version}`, {
// return request(`file/${params.fileId}/${params.version}`, {
// method: 'DELETE'
// }).then((json) => {
// const args = {
@@ -49,6 +57,4 @@ const VRCPlusIconsReq = {
// }
};
// #endregion
export default VRCPlusIconsReq;

View File

@@ -1,9 +1,15 @@
import { request } from '../service/request';
import { useUserStore } from '../stores';
function getCurrentUserId() {
return useUserStore().currentUser.id;
}
const vrcPlusImageReq = {
uploadGalleryImage(imageData) {
const params = {
tag: 'gallery'
};
return window.API.call('file/image', {
return request('file/image', {
uploadImage: true,
matchingDimensions: false,
postData: JSON.stringify(params),
@@ -13,13 +19,12 @@ const vrcPlusImageReq = {
json,
params
};
window.API.$emit('GALLERYIMAGE:ADD', args);
return args;
});
},
uploadSticker(imageData, params) {
return window.API.call('file/image', {
return request('file/image', {
uploadImage: true,
matchingDimensions: true,
postData: JSON.stringify(params),
@@ -29,13 +34,12 @@ const vrcPlusImageReq = {
json,
params
};
window.API.$emit('STICKER:ADD', args);
return args;
});
},
getPrints(params) {
return window.API.call(`prints/user/${window.API.currentUser.id}`, {
return request(`prints/user/${getCurrentUserId()}`, {
method: 'GET',
params
}).then((json) => {
@@ -48,20 +52,19 @@ const vrcPlusImageReq = {
},
deletePrint(printId) {
return window.API.call(`prints/${printId}`, {
return request(`prints/${printId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
printId
};
// window.API.$emit('PRINT:DELETE', args);
return args;
});
},
uploadPrint(imageData, cropWhiteBorder, params) {
return window.API.call('prints', {
return request('prints', {
uploadImagePrint: true,
cropWhiteBorder,
postData: JSON.stringify(params),
@@ -71,26 +74,24 @@ const vrcPlusImageReq = {
json,
params
};
window.API.$emit('PRINT:ADD', args);
return args;
});
},
getPrint(params) {
return window.API.call(`prints/${params.printId}`, {
return request(`prints/${params.printId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('PRINT', args);
return args;
});
},
uploadEmoji(imageData, params) {
return window.API.call('file/image', {
return request('file/image', {
uploadImage: true,
matchingDimensions: true,
postData: JSON.stringify(params),
@@ -100,15 +101,12 @@ const vrcPlusImageReq = {
json,
params
};
window.API.$emit('EMOJI:ADD', args);
return args;
});
}
// ----------- no place uses this function ------------
// editPrint(params) {
// return window.API.call(`prints/${params.printId}`, {
// return request(`prints/${params.printId}`, {
// method: 'POST',
// params
// }).then((json) => {
@@ -116,7 +114,7 @@ const vrcPlusImageReq = {
// json,
// params
// };
// window.API.$emit('PRINT:EDIT', args);
// API.$emit('PRINT:EDIT', args);
// return args;
// });
// },

View File

@@ -1,4 +1,5 @@
// #region | API: World
import { request } from '../service/request';
import { useWorldStore } from '../stores';
const worldReq = {
/**
@@ -6,14 +7,15 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
getWorld(params) {
return window.API.call(`worlds/${params.worldId}`, {
const worldStore = useWorldStore();
return request(`worlds/${params.worldId}`, {
method: 'GET'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('WORLD', args);
args.ref = worldStore.applyWorld(json);
return args;
});
},
@@ -23,10 +25,17 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
getCachedWorld(params) {
const worldStore = useWorldStore();
return new Promise((resolve, reject) => {
const ref = window.API.cachedWorlds.get(params.worldId);
const ref = worldStore.cachedWorlds.get(params.worldId);
if (typeof ref === 'undefined') {
worldReq.getWorld(params).catch(reject).then(resolve);
worldReq
.getWorld(params)
.catch(reject)
.then((args) => {
args.ref = worldStore.applyWorld(args.json);
resolve(args);
});
} else {
resolve({
cache: true,
@@ -57,11 +66,12 @@ const worldReq = {
* @returns {Promise<{json: any, params, option}>}
*/
getWorlds(params, option) {
const worldStore = useWorldStore();
let endpoint = 'worlds';
if (typeof option !== 'undefined') {
endpoint = `worlds/${option}`;
}
return window.API.call(endpoint, {
return request(endpoint, {
method: 'GET',
params
}).then((json) => {
@@ -70,7 +80,9 @@ const worldReq = {
params,
option
};
window.API.$emit('WORLD:LIST', args);
for (const json of args.json) {
worldStore.applyWorld(json);
}
return args;
});
},
@@ -79,14 +91,13 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
deleteWorld(params) {
return window.API.call(`worlds/${params.worldId}`, {
return request(`worlds/${params.worldId}`, {
method: 'DELETE'
}).then((json) => {
const args = {
json,
params
};
window.API.$emit('WORLD:DELETE', args);
return args;
});
},
@@ -96,7 +107,8 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
saveWorld(params) {
return window.API.call(`worlds/${params.id}`, {
const worldStore = useWorldStore();
return request(`worlds/${params.id}`, {
method: 'PUT',
params
}).then((json) => {
@@ -104,7 +116,7 @@ const worldReq = {
json,
params
};
window.API.$emit('WORLD:SAVE', args);
args.ref = worldStore.applyWorld(json);
return args;
});
},
@@ -114,7 +126,8 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
publishWorld(params) {
return window.API.call(`worlds/${params.worldId}/publish`, {
const worldStore = useWorldStore();
return request(`worlds/${params.worldId}/publish`, {
method: 'PUT',
params
}).then((json) => {
@@ -122,7 +135,7 @@ const worldReq = {
json,
params
};
window.API.$emit('WORLD:SAVE', args);
args.ref = worldStore.applyWorld(json);
return args;
});
},
@@ -132,7 +145,8 @@ const worldReq = {
* @returns {Promise<{json: any, params}>}
*/
unpublishWorld(params) {
return window.API.call(`worlds/${params.worldId}/publish`, {
const worldStore = useWorldStore();
return request(`worlds/${params.worldId}/publish`, {
method: 'DELETE',
params
}).then((json) => {
@@ -140,12 +154,10 @@ const worldReq = {
json,
params
};
window.API.$emit('WORLD:SAVE', args);
args.ref = worldStore.applyWorld(json);
return args;
});
}
};
// #endregion
export default worldReq;