mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
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:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user