Skip to content

Commit

Permalink
Fix updating status message with same visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Jun 23, 2024
1 parent 95b7e36 commit a37f76e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,32 @@ export class StatusChangeForPlayerCountAutomationService {
)
.subscribe(async (newStatus) => {
// Set new status
await this.vrchat.setStatus(newStatus.status, newStatus.statusMessage);
if (await this.notifications.notificationTypeEnabled('AUTO_UPDATED_VRC_STATUS')) {
await this.notifications.send(
this.translate.instant('notifications.vrcStatusChanged.content', {
newStatus: (
(newStatus.statusMessage ?? newStatus.oldStatusMessage) +
' (' +
(newStatus.status ?? newStatus.oldStatus) +
')'
).trim(),
})
);
let success = await this.vrchat
.setStatus(newStatus.status, newStatus.statusMessage)
.catch(() => false);
if (success) {
if (await this.notifications.notificationTypeEnabled('AUTO_UPDATED_VRC_STATUS')) {
await this.notifications.send(
this.translate.instant('notifications.vrcStatusChanged.content', {
newStatus: (
(newStatus.statusMessage ?? newStatus.oldStatusMessage) +
' (' +
(newStatus.status ?? newStatus.oldStatus) +
')'
).trim(),
})
);
}
this.eventLog.logEvent({
type: 'statusChangedOnPlayerCountChange',
reason: newStatus.reason,
threshold: this.config.limit,
newStatus: newStatus.status,
oldStatus: newStatus.oldStatus,
newStatusMessage: newStatus.statusMessage,
oldStatusMessage: newStatus.oldStatusMessage,
} as EventLogStatusChangedOnPlayerCountChange);
}
this.eventLog.logEvent({
type: 'statusChangedOnPlayerCountChange',
reason: newStatus.reason,
threshold: this.config.limit,
newStatus: newStatus.status,
oldStatus: newStatus.oldStatus,
newStatusMessage: newStatus.statusMessage,
oldStatusMessage: newStatus.oldStatusMessage,
} as EventLogStatusChangedOnPlayerCountChange);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,29 @@ export class StatusChangeGeneralEventsAutomationService {
.subscribe(async ({ status, statusMessage, sleepMode }) => {
const oldStatus = this.vrcUser?.status;
const oldStatusMessage = this.vrcUser?.statusDescription;
await this.vrchat.setStatus(status, statusMessage);
if (await this.notifications.notificationTypeEnabled('AUTO_UPDATED_VRC_STATUS')) {
await this.notifications.send(
this.translate.instant('notifications.vrcStatusChanged.content', {
newStatus: (
(statusMessage ?? oldStatusMessage) +
' (' +
(status ?? oldStatus) +
')'
).trim(),
})
);
const success = await this.vrchat.setStatus(status, statusMessage).catch((e) => false);
if (success) {
if (await this.notifications.notificationTypeEnabled('AUTO_UPDATED_VRC_STATUS')) {
await this.notifications.send(
this.translate.instant('notifications.vrcStatusChanged.content', {
newStatus: (
(statusMessage ?? oldStatusMessage) +
' (' +
(status ?? oldStatus) +
')'
).trim(),
})
);
}
this.eventLog.logEvent({
type: 'statusChangedOnGeneralEvent',
reason: sleepMode ? 'SLEEP_MODE_ENABLED' : 'SLEEP_MODE_DISABLED',
newStatus: status,
oldStatus: oldStatus,
newStatusMessage: statusMessage,
oldStatusMessage: oldStatusMessage,
} as EventLogStatusChangedOnGeneralEvent);
}
this.eventLog.logEvent({
type: 'statusChangedOnGeneralEvent',
reason: sleepMode ? 'SLEEP_MODE_ENABLED' : 'SLEEP_MODE_DISABLED',
newStatus: status,
oldStatus: oldStatus,
newStatusMessage: statusMessage,
oldStatusMessage: oldStatusMessage,
} as EventLogStatusChangedOnGeneralEvent);
});
}

Expand Down
2 changes: 2 additions & 0 deletions src-ui/app/services/vrchat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ export class VRChatService {
if (!result.result?.ok) throw result.result;
} catch (e) {
error(`[VRChat] Failed to update status: ${JSON.stringify(e)}`);
return false;
}
return true;
}

public showLoginModal(autoLogin = false) {
Expand Down

0 comments on commit a37f76e

Please sign in to comment.