mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 07:13:51 +02:00
refactor store
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { patchAndRefetchActiveQuery, queryKeys } from '../queries';
|
||||
import { request } from '../service/request';
|
||||
import { useUserStore } from '../stores';
|
||||
import { applyUser, applyCurrentUser } from '../coordinators/userCoordinator';
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
@@ -16,7 +17,7 @@ const userReq = {
|
||||
* @type {import('../types/api/user').GetUser}
|
||||
*/
|
||||
getUser(params) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
return request(`users/${params.userId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
@@ -29,7 +30,7 @@ const userReq = {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
ref: userStore.applyUser(json)
|
||||
ref: applyUser(json)
|
||||
};
|
||||
return args;
|
||||
});
|
||||
@@ -56,7 +57,7 @@ const userReq = {
|
||||
* @returns {Promise<{json: any, params: {tags: string[]}}>}
|
||||
*/
|
||||
addUserTags(params) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
return request(`users/${getCurrentUserId()}/addTags`, {
|
||||
method: 'POST',
|
||||
params
|
||||
@@ -65,7 +66,7 @@ const userReq = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
userStore.applyCurrentUser(json);
|
||||
applyCurrentUser(json);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
@@ -75,7 +76,7 @@ const userReq = {
|
||||
* @returns {Promise<{json: any, params: {tags: string[]}}>}
|
||||
*/
|
||||
removeUserTags(params) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
return request(`users/${getCurrentUserId()}/removeTags`, {
|
||||
method: 'POST',
|
||||
params
|
||||
@@ -84,7 +85,7 @@ const userReq = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
userStore.applyCurrentUser(json);
|
||||
applyCurrentUser(json);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
@@ -113,7 +114,7 @@ const userReq = {
|
||||
* @type {import('../types/api/user').GetCurrentUser}
|
||||
*/
|
||||
saveCurrentUser(params) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
return request(`users/${getCurrentUserId()}`, {
|
||||
method: 'PUT',
|
||||
params
|
||||
@@ -121,7 +122,7 @@ const userReq = {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
ref: userStore.applyCurrentUser(json)
|
||||
ref: applyCurrentUser(json)
|
||||
};
|
||||
patchAndRefetchActiveQuery({
|
||||
queryKey: queryKeys.user(args.ref.id),
|
||||
|
||||
Reference in New Issue
Block a user