refactor auto change status

This commit is contained in:
pa
2026-02-14 17:07:22 +09:00
parent 64869a218e
commit 4e552bf3b9
5 changed files with 310 additions and 77 deletions
+33 -3
View File
@@ -247,10 +247,40 @@ export const useNotificationStore = defineStore('Notification', () => {
}
if (
generalSettingsStore.autoAcceptInviteRequests ===
'Selected Favorites' &&
!friendStore.localFavoriteFriends.has(ref.senderUserId)
'Selected Favorites'
) {
return;
const groups = generalSettingsStore.autoAcceptInviteGroups;
if (groups.length === 0) {
return;
} else {
let found = false;
for (const groupKey of groups) {
if (groupKey.startsWith('local:')) {
const localGroup = groupKey.slice(6);
const localFavs =
favoriteStore.localFriendFavorites.get(localGroup);
if (localFavs && localFavs.has(ref.senderUserId)) {
found = true;
break;
}
} else {
const remoteFavs =
favoriteStore.cachedFavorites.get(groupKey);
if (
remoteFavs &&
remoteFavs.some(
(f) => f.favoriteId === ref.senderUserId
)
) {
found = true;
break;
}
}
}
if (!found) {
return;
}
}
}
if (!checkCanInvite(currentLocation)) {
return;
+40 -2
View File
@@ -39,7 +39,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
const autoStateChangeAloneDesc = ref('');
const autoStateChangeCompanyDescEnabled = ref(false);
const autoStateChangeCompanyDesc = ref('');
const autoStateChangeGroups = ref([]);
const autoAcceptInviteRequests = ref('Off');
const autoAcceptInviteGroups = ref([]);
async function initGeneralSettings() {
const [
@@ -64,7 +66,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
autoStateChangeAloneDescConfig,
autoStateChangeCompanyDescEnabledConfig,
autoStateChangeCompanyDescConfig,
autoAcceptInviteRequestsConfig
autoStateChangeGroupsStrConfig,
autoAcceptInviteRequestsConfig,
autoAcceptInviteGroupsStrConfig
] = await Promise.all([
configRepository.getBool('VRCX_StartAtWindowsStartup', false),
VRCXStorage.Get('VRCX_StartAsMinimizedState'),
@@ -102,7 +106,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
false
),
configRepository.getString('VRCX_autoStateChangeCompanyDesc', ''),
configRepository.getString('VRCX_autoAcceptInviteRequests', 'Off')
configRepository.getString('VRCX_autoStateChangeGroups', '[]'),
configRepository.getString('VRCX_autoAcceptInviteRequests', 'Off'),
configRepository.getString('VRCX_autoAcceptInviteGroups', '[]')
]);
isStartAtWindowsStartup.value = isStartAtWindowsStartupConfig;
@@ -146,7 +152,13 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
autoStateChangeCompanyDescEnabled.value =
autoStateChangeCompanyDescEnabledConfig;
autoStateChangeCompanyDesc.value = autoStateChangeCompanyDescConfig;
autoStateChangeGroups.value = JSON.parse(
autoStateChangeGroupsStrConfig
);
autoAcceptInviteRequests.value = autoAcceptInviteRequestsConfig;
autoAcceptInviteGroups.value = JSON.parse(
autoAcceptInviteGroupsStrConfig
);
}
initGeneralSettings();
@@ -322,6 +334,17 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
autoStateChangeCompanyDesc.value
);
}
/**
* @param {Array} value
*/
function setAutoStateChangeGroups(value) {
autoStateChangeGroups.value = value;
configRepository.setString(
'VRCX_autoStateChangeGroups',
JSON.stringify(autoStateChangeGroups.value)
);
}
/**
* @param {string} value
*/
@@ -333,6 +356,17 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
);
}
/**
* @param {string[]} value
*/
function setAutoAcceptInviteGroups(value) {
autoAcceptInviteGroups.value = value;
configRepository.setString(
'VRCX_autoAcceptInviteGroups',
JSON.stringify(autoAcceptInviteGroups.value)
);
}
function promptProxySettings() {
// Element Plus: prompt(message, title, options)
modalStore
@@ -398,7 +432,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
autoStateChangeAloneDesc,
autoStateChangeCompanyDescEnabled,
autoStateChangeCompanyDesc,
autoStateChangeGroups,
autoAcceptInviteRequests,
autoAcceptInviteGroups,
setIsStartAtWindowsStartup,
setIsStartAsMinimizedState,
@@ -420,7 +456,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
setAutoStateChangeAloneDesc,
setAutoStateChangeCompanyDescEnabled,
setAutoStateChangeCompanyDesc,
setAutoStateChangeGroups,
setAutoAcceptInviteRequests,
setAutoAcceptInviteGroups,
promptProxySettings
};
});
+33 -1
View File
@@ -1616,7 +1616,39 @@ export const useUserStore = defineStore('User', () => {
let withCompany = locationStore.lastLocation.playerList.size > 1;
if (generalSettingsStore.autoStateChangeNoFriends) {
withCompany = locationStore.lastLocation.friendList.size >= 1;
const selectedGroups = generalSettingsStore.autoStateChangeGroups;
if (selectedGroups.length > 0) {
const groupFriendIds = new Set();
for (const ref of favoriteStore.cachedFavorites.values()) {
if (
ref.type === 'friend' &&
selectedGroups.includes(ref.$groupKey)
) {
groupFriendIds.add(ref.favoriteId);
}
}
for (const selectedKey of selectedGroups) {
if (selectedKey.startsWith('local:')) {
const groupName = selectedKey.slice(6);
const userIds =
favoriteStore.localFriendFavorites[groupName];
if (userIds) {
for (let i = 0; i < userIds.length; ++i) {
groupFriendIds.add(userIds[i]);
}
}
}
}
withCompany = false;
for (const friendId of locationStore.lastLocation.friendList.keys()) {
if (groupFriendIds.has(friendId)) {
withCompany = true;
break;
}
}
} else {
withCompany = locationStore.lastLocation.friendList.size >= 1;
}
}
const currentStatus = currentUser.value.status;