use action from store instead of directly modifying state in components

This commit is contained in:
pa
2026-03-08 20:15:37 +09:00
parent 3d3ad27ca0
commit eeb5288027
13 changed files with 61 additions and 8 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ const imageReq = {
} catch (error) { } catch (error) {
console.error('Failed to cleanup avatar upload:', error); console.error('Failed to cleanup avatar upload:', error);
} }
avatarStore.avatarDialog.loading = false; avatarStore.setAvatarDialogLoading(false);
}, },
async uploadAvatarImage(params, fileId) { async uploadAvatarImage(params, fileId) {
@@ -154,7 +154,7 @@ const imageReq = {
} catch (error) { } catch (error) {
console.error('Failed to cleanup world upload:', error); console.error('Failed to cleanup world upload:', error);
} }
worldStore.worldDialog.loading = false; worldStore.setWorldDialogLoading(false);
}, },
async uploadWorldImage(params, fileId) { async uploadWorldImage(params, fileId) {
+1 -1
View File
@@ -17,7 +17,7 @@
watch( watch(
() => filterState.search, () => filterState.search,
async (value) => { async (value) => {
globalSearchStore.query = value; globalSearchStore.setQuery(value);
// When query < 2 chars, override the built-in filter // When query < 2 chars, override the built-in filter
// so all items (hint categories) stay visible // so all items (hint categories) stay visible
+1 -1
View File
@@ -167,7 +167,7 @@ export function request(endpoint, options) {
parsed.status === 429 && parsed.status === 429 &&
init.url.endsWith('/instances/groups') init.url.endsWith('/instances/groups')
) { ) {
updateLoopStore.nextGroupInstanceRefresh = 120; // 1min updateLoopStore.setNextGroupInstanceRefresh(120); // 1min
$throw(429, t('api.status_code.429'), endpoint); $throw(429, t('api.status_code.429'), endpoint);
} }
if (parsed.status === 504 || parsed.status === 502) { if (parsed.status === 504 || parsed.status === 502) {
+1 -1
View File
@@ -564,7 +564,7 @@ function handlePipeline(args) {
uiStore.notifyMenu('notification'); uiStore.notifyMenu('notification');
} }
notificationStore.queueNotificationNoty(noty); notificationStore.queueNotificationNoty(noty);
notificationStore.notificationTable.data.push(noty); notificationStore.appendNotificationTableEntry(noty);
sharedFeedStore.addEntry(noty); sharedFeedStore.addEntry(noty);
break; break;
+1 -1
View File
@@ -62,7 +62,7 @@ async function saveUserMemo(id, memo) {
} else { } else {
ref.$nickName = ''; ref.$nickName = '';
} }
userStore.userDialog.memo = memo; userStore.setUserDialogMemo(memo);
} }
} }
+8
View File
@@ -242,6 +242,13 @@ export const useAvatarStore = defineStore('Avatar', () => {
}); });
} }
/**
* @param {boolean} value
*/
function setAvatarDialogLoading(value) {
avatarDialog.value.loading = value;
}
/** /**
* *
* @param {string} avatarId * @param {string} avatarId
@@ -800,6 +807,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
lookupAvatars, lookupAvatars,
selectAvatarWithConfirmation, selectAvatarWithConfirmation,
selectAvatarWithoutConfirmation, selectAvatarWithoutConfirmation,
setAvatarDialogLoading,
showAvatarAuthorDialog, showAvatarAuthorDialog,
addAvatarWearTime, addAvatarWearTime,
preloadOwnAvatars preloadOwnAvatars
+8
View File
@@ -149,6 +149,13 @@ export const useGlobalSearchStore = defineStore('GlobalSearch', () => {
isOpen.value = false; isOpen.value = false;
} }
/**
* @param {string} value
*/
function setQuery(value) {
query.value = value;
}
/** /**
* @param {{id: string, type: string}} item * @param {{id: string, type: string}} item
*/ */
@@ -187,6 +194,7 @@ export const useGlobalSearchStore = defineStore('GlobalSearch', () => {
open, open,
close, close,
setQuery,
selectResult selectResult
}; };
}); });
+9 -1
View File
@@ -392,6 +392,13 @@ export const useNotificationStore = defineStore('Notification', () => {
}); });
} }
/**
* @param {object} entry
*/
function appendNotificationTableEntry(entry) {
notificationTable.value.data.push(entry);
}
/** /**
* *
* @param notificationId * @param notificationId
@@ -1474,6 +1481,7 @@ export const useNotificationStore = defineStore('Notification', () => {
isNotificationExpired, isNotificationExpired,
openNotificationLink, openNotificationLink,
queueMarkAsSeen, queueMarkAsSeen,
markAllAsSeen markAllAsSeen,
appendNotificationTableEntry
}; };
}); });
+5
View File
@@ -151,6 +151,10 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => {
state.nextClearVRCXCacheCheck = value; state.nextClearVRCXCacheCheck = value;
} }
function setNextGroupInstanceRefresh(value) {
state.nextGroupInstanceRefresh = value;
}
return { return {
// state, // state,
@@ -159,6 +163,7 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => {
nextDiscordUpdate, nextDiscordUpdate,
ipcTimeout, ipcTimeout,
updateLoop, updateLoop,
setNextGroupInstanceRefresh,
setNextClearVRCXCacheCheck setNextClearVRCXCacheCheck
}; };
}); });
+8
View File
@@ -1973,6 +1973,13 @@ export const useUserStore = defineStore('User', () => {
sendBoopDialog.value.visible = true; sendBoopDialog.value.visible = true;
} }
/**
* @param {string} value
*/
function setUserDialogMemo(value) {
userDialog.value.memo = value;
}
/** /**
* *
*/ */
@@ -2018,6 +2025,7 @@ export const useUserStore = defineStore('User', () => {
getCurrentUser, getCurrentUser,
handleConfig, handleConfig,
showSendBoopDialog, showSendBoopDialog,
setUserDialogMemo,
checkNote, checkNote,
toggleSharedConnectionsOptOut, toggleSharedConnectionsOptOut,
toggleDiscordFriendsOptOut toggleDiscordFriendsOptOut
+8
View File
@@ -233,6 +233,13 @@ export const useVrcxStore = defineStore('Vrcx', () => {
} }
} }
/**
* @param {string} value
*/
function setProxyServer(value) {
proxyServer.value = value;
}
/** /**
* *
*/ */
@@ -862,6 +869,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
appStartAt, appStartAt,
proxyServer, proxyServer,
setProxyServer,
currentlyDroppingFile, currentlyDroppingFile,
isRegistryBackupDialogVisible, isRegistryBackupDialogVisible,
ipcEnabled, ipcEnabled,
+8
View File
@@ -207,6 +207,13 @@ export const useWorldStore = defineStore('World', () => {
}); });
} }
/**
* @param {boolean} value
*/
function setWorldDialogLoading(value) {
worldDialog.loading = value;
}
/** /**
* *
*/ */
@@ -316,6 +323,7 @@ export const useWorldStore = defineStore('World', () => {
worldDialog, worldDialog,
cachedWorlds, cachedWorlds,
showWorldDialog, showWorldDialog,
setWorldDialogLoading,
updateVRChatWorldCache, updateVRChatWorldCache,
applyWorld, applyWorld,
preloadOwnWorlds preloadOwnWorlds
@@ -102,7 +102,7 @@
} }
async function saveProxy() { async function saveProxy() {
vrcxStore.proxyServer = proxyServerLocal.value; vrcxStore.setProxyServer(proxyServerLocal.value);
await VRCXStorage.Set('VRCX_ProxyServer', vrcxStore.proxyServer); await VRCXStorage.Set('VRCX_ProxyServer', vrcxStore.proxyServer);
await VRCXStorage.Save(); await VRCXStorage.Save();
} }