From 3e2fa5f961765eb51d000230ccfe0487f66c31bb Mon Sep 17 00:00:00 2001 From: Raphiiko Date: Sun, 8 Sep 2024 16:23:53 +0200 Subject: [PATCH] Fixed issue where leave notifications would trigger for every other player when leaving a world. --- CHANGELOG.md | 1 + src-ui/app/services/join-notifications.service.ts | 4 +++- src-ui/app/services/notification.service.ts | 1 + src-ui/app/services/vrchat.service.ts | 6 ++++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e5d06a..a43ba143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Duration inputs for shutdown sequence triggers being broken on systems using a 12-hour clock. - Shutdown sequence being triggered over and over by the sleep mode trigger, when not using it to shut down or reboot the PC. +- Issue where leave notifications would trigger for every other player when leaving a world. ## [1.13.3] diff --git a/src-ui/app/services/join-notifications.service.ts b/src-ui/app/services/join-notifications.service.ts index 675afc2f..995f3f17 100644 --- a/src-ui/app/services/join-notifications.service.ts +++ b/src-ui/app/services/join-notifications.service.ts @@ -11,6 +11,7 @@ import { VRChatService } from './vrchat.service'; import { NotificationService } from './notification.service'; import { concatMap, + delay, distinctUntilChanged, filter, firstValueFrom, @@ -102,7 +103,7 @@ export class JoinNotificationsService { this.vrchat.world .pipe( skip(1), - distinctUntilChanged((a, b) => a.instanceId === b.instanceId) + distinctUntilChanged((a, b) => a.instanceId === b.instanceId && a.loaded === b.loaded) ) .subscribe(() => { this.queuedNotifications = []; @@ -116,6 +117,7 @@ export class JoinNotificationsService { this.queuedNotifications.push(notificationId); return val; }), + delay(500), // Allows queued notifications to be cancelled before they fire in case of a world change concatMap(async (val) => { // Skip if it's ID is not queued if (!this.queuedNotifications.includes(val.id ?? '')) return; diff --git a/src-ui/app/services/notification.service.ts b/src-ui/app/services/notification.service.ts index 6efa2928..fdef34ba 100644 --- a/src-ui/app/services/notification.service.ts +++ b/src-ui/app/services/notification.service.ts @@ -66,6 +66,7 @@ export class NotificationService { public async send(content: string, duration = 3000): Promise { try { const settings = await firstValueFrom(this.appSettingsService.settings); + info(`[Notification] Sending notification (${duration}ms): "${content}"`); switch (settings.notificationProvider) { case 'OYASUMIVR': return await this.sendOyasumiNotification(content, duration); diff --git a/src-ui/app/services/vrchat.service.ts b/src-ui/app/services/vrchat.service.ts index f8197a6b..c1cb5af3 100644 --- a/src-ui/app/services/vrchat.service.ts +++ b/src-ui/app/services/vrchat.service.ts @@ -695,10 +695,12 @@ export class VRChatService { break; } case 'OnPlayerLeft': - this._world.next({ + const context = { ...structuredClone(this._world.value), playerCount: Math.max(this._world.value.playerCount - 1, 0), - }); + }; + if (event.displayName === this._user.value?.displayName) context.loaded = false; + this._world.next(context); break; case 'OnLocationChange': this._world.next({