mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
lint
This commit is contained in:
@@ -11,8 +11,8 @@ import { DataTables } from 'vue-data-tables';
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import ToggleSwitch from 'vuejs-toggle-switch';
|
||||
import VSwatches from 'vue-swatches';
|
||||
Vue.component('v-swatches', VSwatches)
|
||||
import "../node_modules/vue-swatches/dist/vue-swatches.css"
|
||||
Vue.component('v-swatches', VSwatches);
|
||||
import '../node_modules/vue-swatches/dist/vue-swatches.css';
|
||||
import ElementUI from 'element-ui';
|
||||
import locale from 'element-ui/lib/locale/lang/en';
|
||||
|
||||
@@ -4710,7 +4710,7 @@ speechSynthesis.getVoices();
|
||||
$app.methods.updateGameLog = async function () {
|
||||
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;
|
||||
|
||||
switch (gameLog.type) {
|
||||
|
||||
@@ -3,6 +3,45 @@ import sharedRepository, { SharedRepository } from './shared.js';
|
||||
|
||||
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 {
|
||||
async init() {
|
||||
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();
|
||||
window.configRepository = self;
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// requires binding of SharedVariable
|
||||
|
||||
function transformKey(key) {
|
||||
return String(key).toLowerCase();
|
||||
}
|
||||
|
||||
class SharedRepository {
|
||||
remove(key) {
|
||||
key = transformKey(key);
|
||||
@@ -95,10 +99,6 @@ class SharedRepository {
|
||||
setArray(key, value) {
|
||||
this.setObject(key, value);
|
||||
}
|
||||
};
|
||||
|
||||
function transformKey(key) {
|
||||
return String(key).toLowerCase();
|
||||
}
|
||||
|
||||
var self = new SharedRepository();
|
||||
|
||||
@@ -1,46 +1,7 @@
|
||||
// requires binding of LogWatcher
|
||||
|
||||
var contextMap = new Map(); // <string, object>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
// <string, object>
|
||||
var contextMap = new Map();
|
||||
|
||||
function parseRawGameLog(dt, type, args) {
|
||||
var gameLog = {
|
||||
@@ -68,11 +29,57 @@ function parseRawGameLog(dt, type, args) {
|
||||
case 'notification':
|
||||
gameLog.json = args[0];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
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();
|
||||
window.gameLogService = self;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user