From d560aa9836dd5137c1fc03dd27caaa2d5cb58c5d Mon Sep 17 00:00:00 2001 From: Natsumi Date: Thu, 22 Oct 2020 02:40:29 +1300 Subject: [PATCH] Add an option to toggle VR overlay notifications Whoops Whoops 2 --- html/src/app.js | 3 ++ html/src/index.pug | 3 ++ html/src/vr.js | 88 ++++++++++++++++++++++++---------------------- 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 856f1b0a..386f4c7f 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -5482,18 +5482,21 @@ CefSharp.BindObjectAsync( $app.data.hidePrivateFromFeed = VRCXStorage.GetBool('VRCX_hidePrivateFromFeed'); $app.data.hideLoginsFromFeed = VRCXStorage.GetBool('VRCX_hideLoginsFromFeed'); $app.data.hideDevicesFromFeed = VRCXStorage.GetBool('VRCX_hideDevicesFromFeed'); + $app.data.vipNotifications = VRCXStorage.GetBool('VRCX_VIPNotifications'); var saveOpenVROption = function () { VRCXStorage.SetBool('openVR', this.openVR); VRCXStorage.SetBool('openVRAlways', this.openVRAlways); VRCXStorage.SetBool('VRCX_hidePrivateFromFeed', this.hidePrivateFromFeed); VRCXStorage.SetBool('VRCX_hideLoginsFromFeed', this.hideLoginsFromFeed); VRCXStorage.SetBool('VRCX_hideDevicesFromFeed', this.hideDevicesFromFeed); + VRCXStorage.SetBool('VRCX_VIPNotifications', this.vipNotifications); }; $app.watch.openVR = saveOpenVROption; $app.watch.openVRAlways = saveOpenVROption; $app.watch.hidePrivateFromFeed = saveOpenVROption; $app.watch.hideLoginsFromFeed = saveOpenVROption; $app.watch.hideDevicesFromFeed = saveOpenVROption; + $app.watch.vipNotifications = saveOpenVROption; $app.data.isDarkMode = VRCXStorage.GetBool('isDarkMode'); $appDarkStyle.disabled = $app.data.isDarkMode === false; $app.watch.isDarkMode = function () { diff --git a/html/src/index.pug b/html/src/index.pug index 9466a898..fa5ea720 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -506,6 +506,9 @@ html div(style="font-size:12px;margin-top:5px") span(style="display:inline-block;min-width:150px") Hide Private worlds el-switch(v-model="hidePrivateFromFeed") + div(style="font-size:12px;margin-top:5px") + span(style="display:inline-block;min-width:150px") Overlay notifications + el-switch(v-model="vipNotifications") div(style="margin-top:30px") span(style="font-weight:bold") Window div(style="font-size:12px;margin-top:5px") diff --git a/html/src/vr.js b/html/src/vr.js index b5bc142e..a506a9f5 100644 --- a/html/src/vr.js +++ b/html/src/vr.js @@ -705,52 +705,54 @@ CefSharp.BindObjectAsync( if (this.currentUser.status === 'busy') { return; } - var notys = []; - this.feeds.forEach((feed) => { - if (feed.isFavorite) { - if (feed.type === 'Online' || - feed.type === 'Offline') { - if (!map[feed.displayName] || - map[feed.displayName] < feed.created_at) { - map[feed.displayName] = feed.created_at; - notys.push(feed); - } - } else if (feed.type === 'OnPlayerJoined' || - feed.type === 'OnPlayerLeft') { - if (!map[feed.data] || - map[feed.data] < feed.created_at) { - map[feed.data] = feed.created_at; - notys.push(feed); + if (VRCXStorage.GetBool('VRCX_VIPNotifications') === true) { + var notys = []; + this.feeds.forEach((feed) => { + if (feed.isFavorite) { + if (feed.type === 'Online' || + feed.type === 'Offline') { + if (!map[feed.displayName] || + map[feed.displayName] < feed.created_at) { + map[feed.displayName] = feed.created_at; + notys.push(feed); + } + } else if (feed.type === 'OnPlayerJoined' || + feed.type === 'OnPlayerLeft') { + if (!map[feed.data] || + map[feed.data] < feed.created_at) { + map[feed.data] = feed.created_at; + notys.push(feed); + } } } - } - }); - var bias = new Date(Date.now() - 60000).toJSON(); - notys.forEach((noty) => { - if (noty.created_at > bias) { - if (noty.type === 'OnPlayerJoined') { - new Noty({ - type: 'alert', - text: `${noty.data} has joined` - }).show(); - } else if (noty.type === 'OnPlayerLeft') { - new Noty({ - type: 'alert', - text: `${noty.data} has left` - }).show(); - } else if (noty.type === 'Online') { - new Noty({ - type: 'alert', - text: `${noty.displayName} has logged in` - }).show(); - } else if (noty.type === 'Offline') { - new Noty({ - type: 'alert', - text: `${noty.displayName} has logged out` - }).show(); + }); + var bias = new Date(Date.now() - 60000).toJSON(); + notys.forEach((noty) => { + if (noty.created_at > bias) { + if (noty.type === 'OnPlayerJoined') { + new Noty({ + type: 'alert', + text: `${noty.data} has joined` + }).show(); + } else if (noty.type === 'OnPlayerLeft') { + new Noty({ + type: 'alert', + text: `${noty.data} has left` + }).show(); + } else if (noty.type === 'Online') { + new Noty({ + type: 'alert', + text: `${noty.displayName} has logged in` + }).show(); + } else if (noty.type === 'Offline') { + new Noty({ + type: 'alert', + text: `${noty.displayName} has logged out` + }).show(); + } } - } - }); + }); + } } };