mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
lint
This commit is contained in:
+3
-3
@@ -11,8 +11,8 @@ import { DataTables } from 'vue-data-tables';
|
|||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import ToggleSwitch from 'vuejs-toggle-switch';
|
import ToggleSwitch from 'vuejs-toggle-switch';
|
||||||
import VSwatches from 'vue-swatches';
|
import VSwatches from 'vue-swatches';
|
||||||
Vue.component('v-swatches', VSwatches)
|
Vue.component('v-swatches', VSwatches);
|
||||||
import "../node_modules/vue-swatches/dist/vue-swatches.css"
|
import '../node_modules/vue-swatches/dist/vue-swatches.css';
|
||||||
import ElementUI from 'element-ui';
|
import ElementUI from 'element-ui';
|
||||||
import locale from 'element-ui/lib/locale/lang/en';
|
import locale from 'element-ui/lib/locale/lang/en';
|
||||||
|
|
||||||
@@ -4710,7 +4710,7 @@ speechSynthesis.getVoices();
|
|||||||
$app.methods.updateGameLog = async function () {
|
$app.methods.updateGameLog = async function () {
|
||||||
var currentUserDisplayName = API.currentUser.displayName;
|
var currentUserDisplayName = API.currentUser.displayName;
|
||||||
|
|
||||||
for (var gameLog of await gameLogService.poll(API.currentUser.username)) {
|
for (var gameLog of await gameLogService.poll()) {
|
||||||
var tableData = null;
|
var tableData = null;
|
||||||
|
|
||||||
switch (gameLog.type) {
|
switch (gameLog.type) {
|
||||||
|
|||||||
@@ -3,6 +3,45 @@ import sharedRepository, { SharedRepository } from './shared.js';
|
|||||||
|
|
||||||
var dirtyKeySet = new Set();
|
var dirtyKeySet = new Set();
|
||||||
|
|
||||||
|
function transformKey(key) {
|
||||||
|
return `config:${String(key).toLowerCase()}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncLoop() {
|
||||||
|
if (dirtyKeySet.size > 0) {
|
||||||
|
try {
|
||||||
|
await sqliteService.executeNonQuery('BEGIN');
|
||||||
|
try {
|
||||||
|
for (var key of dirtyKeySet) {
|
||||||
|
var value = sharedRepository.getString(key);
|
||||||
|
if (value === null) {
|
||||||
|
await sqliteService.executeNonQuery(
|
||||||
|
'DELETE FROM configs WHERE `key` = @key',
|
||||||
|
{
|
||||||
|
'@key': key
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await sqliteService.executeNonQuery(
|
||||||
|
'INSERT OR REPLACE INTO configs (`key`, `value`) VALUES (@key, @value)',
|
||||||
|
{
|
||||||
|
'@key': key,
|
||||||
|
'@value': value
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dirtyKeySet.clear();
|
||||||
|
} finally {
|
||||||
|
await sqliteService.executeNonQuery('COMMIT');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(syncLoop, 100);
|
||||||
|
}
|
||||||
|
|
||||||
class ConfigRepository extends SharedRepository {
|
class ConfigRepository extends SharedRepository {
|
||||||
async init() {
|
async init() {
|
||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
@@ -34,45 +73,6 @@ class ConfigRepository extends SharedRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformKey(key) {
|
|
||||||
return `config:${String(key).toLowerCase()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function syncLoop() {
|
|
||||||
if (dirtyKeySet.size > 0) {
|
|
||||||
try {
|
|
||||||
await sqliteService.executeNonQuery('BEGIN');
|
|
||||||
try {
|
|
||||||
for (var key of dirtyKeySet) {
|
|
||||||
var value = sharedRepository.getString(key);
|
|
||||||
if (value === null) {
|
|
||||||
await sqliteService.executeNonQuery(
|
|
||||||
'DELETE FROM configs WHERE `key` = @key',
|
|
||||||
{
|
|
||||||
'@key': key,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await sqliteService.executeNonQuery(
|
|
||||||
'INSERT OR REPLACE INTO configs (`key`, `value`) VALUES (@key, @value)',
|
|
||||||
{
|
|
||||||
'@key': key,
|
|
||||||
'@value': value
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dirtyKeySet.clear();
|
|
||||||
} finally {
|
|
||||||
await sqliteService.executeNonQuery('COMMIT');
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setTimeout(syncLoop, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
var self = new ConfigRepository();
|
var self = new ConfigRepository();
|
||||||
window.configRepository = self;
|
window.configRepository = self;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
// requires binding of SharedVariable
|
// requires binding of SharedVariable
|
||||||
|
|
||||||
|
function transformKey(key) {
|
||||||
|
return String(key).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
class SharedRepository {
|
class SharedRepository {
|
||||||
remove(key) {
|
remove(key) {
|
||||||
key = transformKey(key);
|
key = transformKey(key);
|
||||||
@@ -95,10 +99,6 @@ class SharedRepository {
|
|||||||
setArray(key, value) {
|
setArray(key, value) {
|
||||||
this.setObject(key, value);
|
this.setObject(key, value);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
function transformKey(key) {
|
|
||||||
return String(key).toLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = new SharedRepository();
|
var self = new SharedRepository();
|
||||||
|
|||||||
+48
-41
@@ -1,46 +1,7 @@
|
|||||||
// requires binding of LogWatcher
|
// requires binding of LogWatcher
|
||||||
|
|
||||||
var contextMap = new Map(); // <string, object>
|
// <string, object>
|
||||||
|
var contextMap = new Map();
|
||||||
class GameLogService {
|
|
||||||
async poll(loginUser) {
|
|
||||||
var rawGameLogs = await LogWatcher.Get();
|
|
||||||
var gameLogs = [];
|
|
||||||
var now = Date.now();
|
|
||||||
|
|
||||||
for (var [fileName, dt, type, ...args] of rawGameLogs) {
|
|
||||||
var context = contextMap.get(fileName);
|
|
||||||
if (context === undefined) {
|
|
||||||
context = {
|
|
||||||
updatedAt: null,
|
|
||||||
|
|
||||||
// location
|
|
||||||
location: null,
|
|
||||||
};
|
|
||||||
contextMap.set(fileName, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
var gameLog = parseRawGameLog(dt, type, args);
|
|
||||||
|
|
||||||
switch (gameLog.type) {
|
|
||||||
case 'location':
|
|
||||||
context.location = gameLog.location;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.updatedAt = now;
|
|
||||||
|
|
||||||
gameLogs.push(gameLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
return gameLogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
async reset() {
|
|
||||||
await LogWatcher.Reset();
|
|
||||||
contextMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseRawGameLog(dt, type, args) {
|
function parseRawGameLog(dt, type, args) {
|
||||||
var gameLog = {
|
var gameLog = {
|
||||||
@@ -68,11 +29,57 @@ function parseRawGameLog(dt, type, args) {
|
|||||||
case 'notification':
|
case 'notification':
|
||||||
gameLog.json = args[0];
|
gameLog.json = args[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gameLog;
|
return gameLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GameLogService {
|
||||||
|
async poll() {
|
||||||
|
var rawGameLogs = await LogWatcher.Get();
|
||||||
|
var gameLogs = [];
|
||||||
|
var now = Date.now();
|
||||||
|
|
||||||
|
for (var [fileName, dt, type, ...args] of rawGameLogs) {
|
||||||
|
var context = contextMap.get(fileName);
|
||||||
|
if (typeof context === 'undefined') {
|
||||||
|
context = {
|
||||||
|
updatedAt: null,
|
||||||
|
|
||||||
|
// location
|
||||||
|
location: null
|
||||||
|
};
|
||||||
|
contextMap.set(fileName, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
var gameLog = parseRawGameLog(dt, type, args);
|
||||||
|
|
||||||
|
switch (gameLog.type) {
|
||||||
|
case 'location':
|
||||||
|
context.location = gameLog.location;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.updatedAt = now;
|
||||||
|
|
||||||
|
gameLogs.push(gameLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameLogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
async reset() {
|
||||||
|
await LogWatcher.Reset();
|
||||||
|
contextMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var self = new GameLogService();
|
var self = new GameLogService();
|
||||||
window.gameLogService = self;
|
window.gameLogService = self;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user