Auto change status updates

This commit is contained in:
Natsumi
2024-12-07 20:05:08 +13:00
parent d950153668
commit a34f778937
3 changed files with 147 additions and 49 deletions

View File

@@ -6191,9 +6191,20 @@ speechSynthesis.getVoices();
return length; return length;
}; };
$app.data.instanceTypes = [
'invite',
'invite+',
'friends',
'friends+',
'public',
'groupPublic',
'groupPlus',
'groupOnly'
];
$app.methods.updateAutoStateChange = function () { $app.methods.updateAutoStateChange = function () {
if ( if (
this.autoStateChange === 'Off' || !this.autoStateChangeEnabled ||
!this.isGameRunning || !this.isGameRunning ||
!this.lastLocation.playerList.size || !this.lastLocation.playerList.size ||
this.lastLocation.location === '' || this.lastLocation.location === '' ||
@@ -6202,38 +6213,50 @@ speechSynthesis.getVoices();
return; return;
} }
const otherPeopleExists = this.lastLocation.playerList.size > 1; var $location = $utils.parseLocation(this.lastLocation.location);
const prevStatus = API.currentUser.status; var instanceType = $location.accessType;
let nextStatus = prevStatus; if (instanceType === 'group') {
if ($location.groupAccessType === 'members') {
switch (this.autoStateChange) { instanceType = 'groupOnly';
case 'Active or Ask Me': } else if ($location.groupAccessType === 'plus') {
nextStatus = otherPeopleExists ? 'ask me' : 'active'; instanceType = 'groupPlus';
break; } else {
instanceType = 'groupPublic';
case 'Active or Busy': }
nextStatus = otherPeopleExists ? 'busy' : 'active'; }
break; if (
this.autoStateChangeInstanceTypes.length > 0 &&
case 'Join Me or Ask Me': !this.autoStateChangeInstanceTypes.includes(instanceType)
nextStatus = otherPeopleExists ? 'ask me' : 'join me'; ) {
break; return;
case 'Join Me or Busy':
nextStatus = otherPeopleExists ? 'busy' : 'join me';
break;
case 'Ask Me or Busy':
nextStatus = otherPeopleExists ? 'ask me' : 'busy';
break;
} }
if (prevStatus === nextStatus) { var withCompany = this.lastLocation.playerList.size > 1;
if (this.autoStateChangeNoFriends) {
withCompany = this.lastLocation.friendList.size > 1;
}
var currentStatus = API.currentUser.status;
var newStatus = withCompany
? this.autoStateChangeCompanyStatus
: this.autoStateChangeAloneStatus;
if (currentStatus === newStatus) {
return; return;
} }
API.saveCurrentUser({ API.saveCurrentUser({
status: nextStatus status: newStatus
}).then(() => {
var text = `Status automaticly changed to ${newStatus}`;
if (this.errorNoty) {
this.errorNoty.close();
}
this.errorNoty = new Noty({
type: 'info',
text
}).show();
console.log(text);
}); });
}; };
@@ -7434,7 +7457,15 @@ speechSynthesis.getVoices();
ref.senderUserId ref.senderUserId
) )
.then((_args) => { .then((_args) => {
$app.$message(`Auto invite sent to ${ref.senderUsername}`); var text = `Auto invite sent to ${ref.senderUsername}`;
if (this.errorNoty) {
this.errorNoty.close();
}
this.errorNoty = new Noty({
type: 'info',
text
}).show();
console.log(text);
API.hideNotification({ API.hideNotification({
notificationId: ref.id notificationId: ref.id
}); });
@@ -8371,18 +8402,52 @@ speechSynthesis.getVoices();
this.logEmptyAvatars this.logEmptyAvatars
); );
}; };
$app.data.autoStateChange = await configRepository.getString( $app.data.autoStateChangeEnabled = await configRepository.getBool(
'VRCX_autoStateChange', 'VRCX_autoStateChangeEnabled',
'Off' false
);
$app.data.autoStateChangeNoFriends = await configRepository.getBool(
'VRCX_autoStateChangeNoFriends',
false
);
$app.data.autoStateChangeInstanceTypes = JSON.parse(
await configRepository.getString(
'VRCX_autoStateChangeInstanceTypes',
'[]'
)
);
$app.data.autoStateChangeAloneStatus = await configRepository.getString(
'VRCX_autoStateChangeAloneStatus',
'join me'
);
$app.data.autoStateChangeCompanyStatus = await configRepository.getString(
'VRCX_autoStateChangeCompanyStatus',
'busy'
); );
$app.data.autoAcceptInviteRequests = await configRepository.getString( $app.data.autoAcceptInviteRequests = await configRepository.getString(
'VRCX_autoAcceptInviteRequests', 'VRCX_autoAcceptInviteRequests',
'Off' 'Off'
); );
$app.methods.saveAutomationOptions = async function () { $app.methods.saveAutomationOptions = async function () {
await configRepository.setBool(
'VRCX_autoStateChangeEnabled',
this.autoStateChangeEnabled
);
await configRepository.setBool(
'VRCX_autoStateChangeNoFriends',
this.autoStateChangeNoFriends
);
await configRepository.setString( await configRepository.setString(
'VRCX_autoStateChange', 'VRCX_autoStateChangeInstanceTypes',
this.autoStateChange JSON.stringify(this.autoStateChangeInstanceTypes)
);
await configRepository.setString(
'VRCX_autoStateChangeAloneStatus',
this.autoStateChangeAloneStatus
);
await configRepository.setString(
'VRCX_autoStateChangeCompanyStatus',
this.autoStateChangeCompanyStatus
); );
await configRepository.setString( await configRepository.setString(
'VRCX_autoAcceptInviteRequests', 'VRCX_autoAcceptInviteRequests',

View File

@@ -242,14 +242,15 @@
}, },
"automation": { "automation": {
"header": "Automation", "header": "Automation",
"auto_state_change": "Auto Status Change", "auto_change_status": "Auto Change Status",
"auto_state_change_tooltip": "Automatically change status when there are other people in the instance (Alone / Company)", "auto_state_change_tooltip": "Automatically change status when there are other people in the instance (Alone / Company)",
"auto_state_change_off": "Off", "alone_condition": "Alone Condition",
"auto_state_change_active_or_ask_me": "Active / Ask Me", "alone": "Alone",
"auto_state_change_active_or_busy": "Active / Busy", "no_friends": "No Friends",
"auto_state_change_join_me_or_ask_me": "Join Me / Ask Me", "alone_status": "Alone Status",
"auto_state_change_join_me_or_busy": "Join Me / Busy", "company_status": "Company Status",
"auto_state_change_ask_me_or_busy": "Ask Me / Busy", "allowed_instance_types": "Allowed Instance Types",
"instance_type_placeholder": "All Instance Types",
"auto_invite_request_accept": "Auto Accept Invite Requests", "auto_invite_request_accept": "Auto Accept Invite Requests",
"auto_invite_request_accept_tooltip": "Automatically accept invite requests from favorite friends", "auto_invite_request_accept_tooltip": "Automatically accept invite requests from favorite friends",
"auto_invite_request_accept_off": "Off", "auto_invite_request_accept_off": "Off",

View File

@@ -116,15 +116,47 @@ mixin settingsTab()
span.name(style="min-width:225px") {{ $t('view.settings.general.logging.empty_avatar') }} span.name(style="min-width:225px") {{ $t('view.settings.general.logging.empty_avatar') }}
el-switch(v-model="logEmptyAvatars" @change="saveLoggingOptions") el-switch(v-model="logEmptyAvatars" @change="saveLoggingOptions")
//- General | Automation //- General | Automation
+simpleSettingsCategory("view.settings.general.automation.header") div.options-container
+simpleRadioGroupWithTooltip("view.settings.general.automation.auto_state_change", "$t('view.settings.general.automation.auto_state_change_tooltip')", "autoStateChange", [ span.header {{ $t('view.settings.general.automation.header') }}
{ label: "Off", translationKey: "view.settings.general.automation.auto_state_change_off" }, div.options-container-item
{ label: "Active or Ask Me", translationKey: "view.settings.general.automation.auto_state_change_active_or_ask_me" }, span.name {{ $t('view.settings.general.automation.auto_change_status') }}
{ label: "Active or Busy", translationKey: "view.settings.general.automation.auto_state_change_active_or_busy" }, el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.general.automation.auto_state_change_tooltip')")
{ label: "Join Me or Ask Me", translationKey: "view.settings.general.automation.auto_state_change_join_me_or_ask_me" }, i.el-icon-info
{ label: "Join Me or Busy", translationKey: "view.settings.general.automation.auto_state_change_join_me_or_busy" }, el-switch(v-model="autoStateChangeEnabled" @change="saveAutomationOptions")
{ label: "Ask Me or Busy", translationKey: "view.settings.general.automation.auto_state_change_ask_me_or_busy" }, div.options-container-item
], "saveAutomationOptions") span.name {{ $t('view.settings.general.automation.alone_status') }}
el-select(v-model="autoStateChangeAloneStatus" :disabled="!autoStateChangeEnabled" @change="saveAutomationOptions" style="margin-top:8px")
el-option(:label="$t('dialog.user.status.join_me')" value="join me").
#[i.x-user-status.joinme] {{ $t('dialog.user.status.join_me') }}
el-option(:label="$t('dialog.user.status.online')" value="active").
#[i.x-user-status.online] {{ $t('dialog.user.status.online') }}
el-option(:label="$t('dialog.user.status.ask_me')" value="ask me").
#[i.x-user-status.askme] {{ $t('dialog.user.status.ask_me') }}
el-option(:label="$t('dialog.user.status.busy')" value="busy").
#[i.x-user-status.busy] {{ $t('dialog.user.status.busy') }}
div.options-container-item
span.name {{ $t('view.settings.general.automation.company_status') }}
el-select(v-model="autoStateChangeCompanyStatus" :disabled="!autoStateChangeEnabled" @change="saveAutomationOptions" style="margin-top:8px")
el-option(:label="$t('dialog.user.status.join_me')" value="join me").
#[i.x-user-status.joinme] {{ $t('dialog.user.status.join_me') }}
el-option(:label="$t('dialog.user.status.online')" value="active").
#[i.x-user-status.online] {{ $t('dialog.user.status.online') }}
el-option(:label="$t('dialog.user.status.ask_me')" value="ask me").
#[i.x-user-status.askme] {{ $t('dialog.user.status.ask_me') }}
el-option(:label="$t('dialog.user.status.busy')" value="busy").
#[i.x-user-status.busy] {{ $t('dialog.user.status.busy') }}
div.options-container-item
span.name {{ $t('view.settings.general.automation.allowed_instance_types') }}
el-select(v-model="autoStateChangeInstanceTypes" :disabled="!autoStateChangeEnabled" multiple clearable :placeholder="$t('view.settings.general.automation.instance_type_placeholder')" @change="saveAutomationOptions" style="margin-top:8px")
el-option-group(:label="$t('view.settings.general.automation.allowed_instance_types')")
el-option.x-friend-item(v-for="instanceType in instanceTypes" :key="instanceType" :label="instanceType" :value="instanceType")
.detail
span.name(v-text="instanceType")
div.options-container-item
span.name {{ $t('view.settings.general.automation.alone_condition') }}
el-switch(v-model="autoStateChangeNoFriends" :disabled="!autoStateChangeEnabled" @change="saveAutomationOptions" :inactive-text="$t('view.settings.general.automation.alone')" :active-text="$t('view.settings.general.automation.no_friends')")
br
br
+simpleRadioGroupWithTooltip("view.settings.general.automation.auto_invite_request_accept", "$t('view.settings.general.automation.auto_invite_request_accept_tooltip')", "autoAcceptInviteRequests", [ +simpleRadioGroupWithTooltip("view.settings.general.automation.auto_invite_request_accept", "$t('view.settings.general.automation.auto_invite_request_accept_tooltip')", "autoAcceptInviteRequests", [
{ label: "Off", translationKey: "view.settings.general.automation.auto_invite_request_accept_off" }, { label: "Off", translationKey: "view.settings.general.automation.auto_invite_request_accept_off" },
{ label: "All Favorites", translationKey: "view.settings.general.automation.auto_invite_request_accept_favs" }, { label: "All Favorites", translationKey: "view.settings.general.automation.auto_invite_request_accept_favs" },