From 2fd992edf75df68cb808867912d2baf49f6e86d0 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Tue, 13 Dec 2022 19:11:25 +1300 Subject: [PATCH] Debug logging message, custom script --- AppApi.cs | 9 +++++++++ LogWatcher.cs | 16 +++++++++++++++- html/src/app.js | 39 +++++++++++++++++++++++++++++++++------ html/src/index.pug | 4 +--- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/AppApi.cs b/AppApi.cs index e63ad649..25351c27 100644 --- a/AppApi.cs +++ b/AppApi.cs @@ -373,6 +373,15 @@ namespace VRCX return output; } + public string CustomScriptPath() + { + var output = String.Empty; + var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VRCX\\custom.js"); + if (File.Exists(filePath)) + output = filePath; + return output; + } + public string CurrentCulture() { return System.Globalization.CultureInfo.CurrentCulture.ToString(); diff --git a/LogWatcher.cs b/LogWatcher.cs index 3498fe86..cafb09b9 100644 --- a/LogWatcher.cs +++ b/LogWatcher.cs @@ -37,6 +37,7 @@ namespace VRCX private Thread m_Thread; private bool m_ResetLog; private bool m_FirstRun = true; + private bool m_NullLogMsg; private static DateTime tillDate = DateTime.Now; // NOTE @@ -94,7 +95,7 @@ namespace VRCX { Thread.Sleep(1000); } - catch(ThreadInterruptedException) + catch (ThreadInterruptedException) { } } @@ -128,8 +129,10 @@ namespace VRCX // sort by creation time Array.Sort(fileInfos, (a, b) => a.CreationTimeUtc.CompareTo(b.CreationTimeUtc)); + var index = 0; foreach (var fileInfo in fileInfos) { + index++; fileInfo.Refresh(); if (fileInfo.Exists == false) { @@ -151,6 +154,17 @@ namespace VRCX m_LogContextMap.Add(fileInfo.Name, logContext); } + if (!m_NullLogMsg && fileInfo.Length == 0 && index == fileInfos.Length) + { + // check if last file is empty + Console.WriteLine($"{fileInfo.Name}"); + if (MainForm.Instance != null && MainForm.Instance.Browser != null) + { + MainForm.Instance.Browser.ExecuteScriptAsync("$app.showNullLogWarning()"); + m_NullLogMsg = true; + } + } + if (logContext.Length == fileInfo.Length) { continue; diff --git a/html/src/app.js b/html/src/app.js index b1a2cd94..99ae0b32 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -4621,6 +4621,7 @@ speechSynthesis.getVoices(); this.updateLoop(); this.getGameLogTable(); this.refreshCustomCss(); + this.refreshCustomScript(); this.$nextTick(function () { this.$el.style.display = ''; if (!this.enablePrimaryPassword) { @@ -4659,6 +4660,21 @@ speechSynthesis.getVoices(); }); }; + $app.methods.refreshCustomScript = function () { + if (document.contains(document.getElementById('app-custom-script'))) { + document.getElementById('app-custom-script').remove(); + } + AppApi.CustomScriptPath().then((customScript) => { + var head = document.head; + if (customScript) { + var $appCustomScript = document.createElement('script'); + $appCustomScript.setAttribute('id', 'app-custom-script'); + $appCustomScript.src = `file://${customScript}?_=${Date.now()}`; + head.appendChild($appCustomScript); + } + }); + }; + $app.methods.openExternalLink = function (link) { this.$confirm(`${link}`, 'Open External Link', { confirmButtonText: 'Confirm', @@ -6334,7 +6350,7 @@ speechSynthesis.getVoices(); callback: (action, instance) => { if (action === 'confirm') { API.verifyTOTP({ - code: instance.inputValue + code: instance.inputValue.trim() }) .catch((err) => { this.promptTOTP(); @@ -6366,7 +6382,7 @@ speechSynthesis.getVoices(); callback: (action, instance) => { if (action === 'confirm') { API.verifyOTP({ - code: instance.inputValue + code: instance.inputValue.trim() }) .catch((err) => { this.promptOTP(); @@ -6398,7 +6414,7 @@ speechSynthesis.getVoices(); callback: (action, instance) => { if (action === 'confirm') { API.verifyEmailOTP({ - code: instance.inputValue + code: instance.inputValue.trim() }) .catch((err) => { this.promptEmailOTP(); @@ -20336,7 +20352,11 @@ speechSynthesis.getVoices(); $app.methods.checkCanInvite = function (location) { var L = API.parseLocation(location); - if (L.accessType === 'public' || L.userId === API.currentUser.id) { + if ( + L.accessType === 'public' || + L.accessType === 'group' || + L.userId === API.currentUser.id + ) { return true; } if (L.accessType === 'invite') { @@ -22889,7 +22909,7 @@ speechSynthesis.getVoices(); }); if ($app.groupDialog.visible && $app.groupDialog.id === groupId) { $app.groupDialog.inGroup = json.membershipStatus === 'member'; - this.getGroupDialogGroup(groupId); + $app.getGroupDialogGroup(groupId); } }); @@ -22915,7 +22935,7 @@ speechSynthesis.getVoices(); var groupId = args.params.groupId; if ($app.groupDialog.visible && $app.groupDialog.id === groupId) { $app.groupDialog.inGroup = false; - this.getGroupDialogGroup(groupId); + $app.getGroupDialogGroup(groupId); } if ( $app.userDialog.visible && @@ -23780,6 +23800,13 @@ speechSynthesis.getVoices(); } }; + $app.methods.showNullLogWarning = function () { + this.$alert( + 'VRCX noticed your last log file is empty this is normally caused by disabling debug logging. VRCX requires debug logging to be enabled to function correctly. Please enable debug logging in VRChat quick menu settings > debug > enable debug logging, then rejoin the instance or restart VRChat.', + 'Enable debug logging' + ); + }; + $app = new Vue($app); window.$app = $app; })(); diff --git a/html/src/index.pug b/html/src/index.pug index 3e355b86..897150f0 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -2242,17 +2242,15 @@ html el-button(type="default" icon="el-icon-more" circle) el-dropdown-menu(#default="dropdown") el-dropdown-item(icon="el-icon-refresh" command="Refresh") Refresh - template(v-if="groupDialog.inGroup") template(v-if="groupDialog.ref.myMember") el-dropdown-item(v-if="groupDialog.ref.myMember.isSubscribedToAnnouncements" icon="el-icon-close" command="Unsubscribe To Announcements" divided) Unsubscribe To Announcements el-dropdown-item(v-else icon="el-icon-check" command="Subscribe To Announcements" divided) Subscribe To Announcements - el-dropdown-item(icon="el-icon-message" command="Invite To Group") Invite To Group + el-dropdown-item(v-if="hasGroupPermission(groupDialog.ref, 'group-invites-manage')" icon="el-icon-message" command="Invite To Group") Invite To Group template(v-if="groupDialog.ref.myMember && groupDialog.ref.privacy === 'default'") el-dropdown-item(icon="el-icon-view" command="Visibility Everyone" divided) #[i.el-icon-check(v-if="groupDialog.ref.myMember.visibility === 'visible'")] Visibility Everyone el-dropdown-item(icon="el-icon-view" command="Visibility Friends") #[i.el-icon-check(v-if="groupDialog.ref.myMember.visibility === 'friends'")] Visibility Friends el-dropdown-item(icon="el-icon-view" command="Visibility Hidden") #[i.el-icon-check(v-if="groupDialog.ref.myMember.visibility === 'hidden'")] Visibility Hidden - el-dropdown-item(icon="el-icon-delete" command="Leave Group" style="color:#F56C6C" divided) Leave Group el-tabs(ref="groupDialogTabs" @tab-click="groupDialogTabClick") el-tab-pane(label="Info")