From 095f9c0d59ca6531dec591e7f535d49702f2b35b Mon Sep 17 00:00:00 2001 From: pypy Date: Sat, 17 Aug 2019 04:13:48 +0900 Subject: [PATCH] v2019.08.17 --- VRCXStorage.cs | 10 ++++++- html/.eslintrc.js | 1 + html/app.js | 70 +++++++++++++++++++++++++++++++++++++++++++---- html/index.html | 2 +- html/vr.js | 18 ++++++++---- 5 files changed, 88 insertions(+), 13 deletions(-) diff --git a/VRCXStorage.cs b/VRCXStorage.cs index f9f8683c..456c5094 100644 --- a/VRCXStorage.cs +++ b/VRCXStorage.cs @@ -11,6 +11,7 @@ namespace VRCX public class VRCXStorage { private static Dictionary m_Storage = new Dictionary(); + private static bool m_Dirty; public static void Load() { @@ -26,6 +27,7 @@ namespace VRCX { lock (m_Storage) { + m_Dirty = true; m_Storage.Clear(); } } @@ -34,7 +36,11 @@ namespace VRCX { lock (m_Storage) { - Save(); + if (m_Dirty) + { + m_Dirty = false; + Save(); + } } } @@ -42,6 +48,7 @@ namespace VRCX { lock (m_Storage) { + m_Dirty = true; return m_Storage.Remove(key); } } @@ -60,6 +67,7 @@ namespace VRCX { lock (m_Storage) { + m_Dirty = true; m_Storage[key] = value; } } diff --git a/html/.eslintrc.js b/html/.eslintrc.js index 419f15c0..ea1ac5a4 100644 --- a/html/.eslintrc.js +++ b/html/.eslintrc.js @@ -32,6 +32,7 @@ module.exports = { 'indent': 0, 'init-declarations': 0, 'linebreak-style': 0, + 'lines-around-comment': 0, 'max-depth': 0, 'max-len': 0, 'max-lines': 0, diff --git a/html/app.js b/html/app.js index ea1a306a..85a8e098 100644 --- a/html/app.js +++ b/html/app.js @@ -84,9 +84,7 @@ if (window.CefSharp) { this.Set(key, JSON.stringify(value)); }; - VRCXStorage.Flush(); - - setInterval(() => VRCXStorage.Flush(), 3 * 60 * 1000); + setInterval(() => VRCXStorage.Flush(), 5 * 60 * 1000); Noty.overrideDefaults({ animation: { @@ -3341,7 +3339,7 @@ if (window.CefSharp) { VRCX, nextRefresh: 0, isGameRunning: false, - appVersion: '2019.08.16', + appVersion: '2019.08.17', latestAppVersion: '', ossDialog: false }, @@ -4201,6 +4199,7 @@ if (window.CefSharp) { API.$on('LOGIN', (args) => { $app.feedTable.data = VRCXStorage.GetArray(`${args.ref.id}_feedTable`); + $app.sweepFeed(); }); API.$on('USER:UPDATE', (args) => { @@ -4268,13 +4267,18 @@ if (window.CefSharp) { }; $app.methods.addFeed = function (type, ref, extra) { - this.feedTable.data.push({ + var array = this.feedTable.data; + if (array.length > 50000) { + array.length.splice(0, array.length - 10000); + } + array.push({ created_at: new Date().toJSON(), type, userId: ref.id, displayName: ref.displayName, ...extra }); + this.sweepFeed(); this.saveFeed(); this.notifyMenu('feed'); }; @@ -4287,12 +4291,48 @@ if (window.CefSharp) { type: 'info', callback: (action) => { if (action === 'confirm') { - this.feedTable.data = []; + // 필터된 데이터만 삭제 하려면.. 허어 + var T = this.feedTable; + T.data = T.data.filter((row) => !T.filters.every((filter) => { + if (filter.value) { + if (!Array.isArray(filter.value)) { + if (filter.filterFn) { + return filter.filterFn(row, filter); + } + return String(row[filter.prop]).toUpperCase().includes(String(filter.value).toUpperCase()); + } + if (filter.value.length) { + if (filter.filterFn) { + return filter.filterFn(row, filter); + } + var prop = String(row[filter.prop]).toUpperCase(); + return filter.value.some((v) => prop.includes(String(v).toUpperCase())); + } + } + return true; + })); } } }); }; + $app.methods.sweepFeed = function () { + var array = this.feedTable.data; + // 로그는 3일까지만 남김 + var limit = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toJSON(); + var i = 0; + var j = array.length; + while (i < j && + array[i].created_at < limit) { + ++i; + } + if (i === j) { + this.feedTable.data = []; + } else if (i) { + array.splice(0, i); + } + }; + // App: gameLog $app.data.lastLocation = ''; @@ -4361,6 +4401,7 @@ if (window.CefSharp) { this.lastLocation = ctx.data; } }); + this.sweepGameLog(); this.updateSharedFeed(); this.notifyMenu('gameLog'); }); @@ -4370,6 +4411,23 @@ if (window.CefSharp) { }); }; + $app.methods.sweepGameLog = function () { + var array = this.gameLogTable.data; + // 로그는 3일까지만 남김 + var limit = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toJSON(); + var i = 0; + var j = array.length; + while (i < j && + array[i].created_at < limit) { + ++i; + } + if (i === j) { + this.gameLogTable.data = []; + } else if (i) { + array.splice(0, i); + } + }; + $app.methods.updateDiscord = function () { if (this.isGameRunning && this.lastLocation) { diff --git a/html/index.html b/html/index.html index 453a4f56..9cad248d 100644 --- a/html/index.html +++ b/html/index.html @@ -1216,7 +1216,7 @@ - Select Avatar + Select Avatar diff --git a/html/vr.js b/html/vr.js index d2a176a3..fbd60d47 100644 --- a/html/vr.js +++ b/html/vr.js @@ -469,13 +469,21 @@ if (window.CefSharp) { } else if (L.worldId) { var ref = API.world[L.worldId]; if (ref) { - this.text = `${ref.name} #${L.instanceName} ${L.accessType}`; + if (L.instanceId) { + this.text = `${ref.name} #${L.instanceName} ${L.accessType}`; + } else { + this.text = ref.name; + } } else { API.getWorld({ worldId: L.worldId }).then((args) => { if (L.tag === this.location) { - this.text = `${args.ref.name} #${L.instanceName} ${L.accessType}`; + if (L.instanceId) { + this.text = `${args.ref.name} #${L.instanceName} ${L.accessType}`; + } else { + this.text = args.ref.name; + } } return args; }); @@ -590,9 +598,9 @@ if (window.CefSharp) { // 현재 날짜 시간 // 컨트롤러 배터리 상황 // -- - // OO is Let's Just H!!!!! [GPS] - // OO has logged in [Online] - // OO has logged out [Offline] + // OO is in Let's Just H!!!!! [GPS] + // OO has logged in [Online] -> TODO: location + // OO has logged out [Offline] -> TODO: location // OO has joined [OnPlayerJoined] // OO has left [OnPlayerLeft] // [Moderation]