refactor store

This commit is contained in:
pa
2026-03-10 15:25:23 +09:00
parent d7220baaf6
commit 95c4a1d3e6
82 changed files with 3243 additions and 3066 deletions

View File

@@ -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),