mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 07:13:51 +02:00
refactor: app.js (#1291)
* refactor: frontend * Fix avatar gallery sort * Update .NET dependencies * Update npm dependencies electron v37.1.0 * bulkRefreshFriends * fix dark theme * Remove crowdin * Fix config.json dialog not updating * VRCX log file fixes & add Cef log * Remove SharedVariable, fix startup * Revert init theme change * Logging date not working? Fix WinformThemer designer error * Add Cef request hander, no more escaping main page * clean * fix * fix * clean * uh * Apply thememode at startup, fixes random user colours * Split database into files * Instance info remove empty lines * Open external VRC links with VRCX * Electron fixes * fix userdialog style * ohhhh * fix store * fix store * fix: load all group members after kicking a user * fix: world dialog favorite button style * fix: Clear VRCX Cache Timer input value * clean * Fix VR overlay * Fix VR overlay 2 * Fix Discord discord rich presence for RPC worlds * Clean up age verified user tags * Fix playerList being occupied after program reload * no `this` * Fix login stuck loading * writable: false * Hide dialogs on logout * add flush sync option * rm LOGIN event * rm LOGOUT event * remove duplicate event listeners * remove duplicate event listeners * clean * remove duplicate event listeners * clean * fix theme style * fix t * clearable * clean * fix ipcEvent * Small changes * Popcorn Palace support * Remove checkActiveFriends * Clean up * Fix dragEnterCef * Block API requests when not logged in * Clear state on login & logout * Fix worldDialog instances not updating * use <script setup> * Fix avatar change event, CheckGameRunning at startup * Fix image dragging * fix * Remove PWI * fix updateLoop * add webpack-dev-server to dev environment * rm unnecessary chunks * use <script setup> * webpack-dev-server changes * use <script setup> * use <script setup> * Fix UGC text size * Split login event * t * use <script setup> * fix * Update .gitignore and enable checkJs in jsconfig * fix i18n t * use <script setup> * use <script setup> * clean * global types * fix * use checkJs for debugging * Add watchState for login watchers * fix .vue template * type fixes * rm Vue.filter * Cef v138.0.170, VC++ 2022 * Settings fixes * Remove 'USER:CURRENT' * clean up 2FA callbacks * remove userApply * rm i18n import * notification handling to use notification store methods * refactor favorite handling to use favorite store methods and clean up event emissions * refactor moderation handling to use dedicated functions for player moderation events * refactor friend handling to use dedicated functions for friend events * Fix program startup, move lang init * Fix friend state * Fix status change error * Fix user notes diff * fix * rm group event * rm auth event * rm avatar event * clean * clean * getUser * getFriends * getFavoriteWorlds, getFavoriteAvatars * AvatarGalleryUpload btn style & package.json update * Fix friend requests * Apply user * Apply world * Fix note diff * Fix VR overlay * Fixes * Update build scripts * Apply avatar * Apply instance * Apply group * update hidden VRC+ badge * Fix sameInstance "private" * fix 502/504 API errors * fix 502/504 API errors * clean * Fix friend in same instance on orange showing twice in friends list * Add back in broken friend state repair methods * add types --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
156
src/service/database/tableFixes.js
Normal file
156
src/service/database/tableFixes.js
Normal file
@@ -0,0 +1,156 @@
|
||||
import sqliteService from '../sqlite.js';
|
||||
import { dbVars } from '../database';
|
||||
|
||||
const tableFixes = {
|
||||
async cleanLegendFromFriendLog() {
|
||||
await sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${dbVars.userPrefix}_friend_log_history
|
||||
WHERE type = 'TrustLevel' AND created_at > '2022-05-04T01:00:00.000Z'
|
||||
AND ((trust_level = 'Veteran User' AND previous_trust_level = 'Trusted User') OR (trust_level = 'Trusted User' AND previous_trust_level = 'Veteran User'))`
|
||||
);
|
||||
},
|
||||
|
||||
async fixGameLogTraveling() {
|
||||
var travelingList = [];
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
location: dbRow[4],
|
||||
userId: dbRow[5],
|
||||
time: dbRow[6]
|
||||
};
|
||||
travelingList.unshift(row);
|
||||
}, 'SELECT * FROM gamelog_join_leave WHERE type = "OnPlayerLeft" AND location = "traveling"');
|
||||
travelingList.forEach(async (travelingEntry) => {
|
||||
await sqliteService.execute(
|
||||
(dbRow) => {
|
||||
var onPlayingJoin = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
location: dbRow[4],
|
||||
userId: dbRow[5],
|
||||
time: dbRow[6]
|
||||
};
|
||||
sqliteService.executeNonQuery(
|
||||
`UPDATE gamelog_join_leave SET location = @location WHERE id = @rowId`,
|
||||
{
|
||||
'@rowId': travelingEntry.rowId,
|
||||
'@location': onPlayingJoin.location
|
||||
}
|
||||
);
|
||||
},
|
||||
'SELECT * FROM gamelog_join_leave WHERE type = "OnPlayerJoined" AND display_name = @displayName AND created_at <= @created_at ORDER BY created_at DESC LIMIT 1',
|
||||
{
|
||||
'@displayName': travelingEntry.displayName,
|
||||
'@created_at': travelingEntry.created_at
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
async fixNegativeGPS() {
|
||||
var gpsTables = [];
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gpsTables.push(dbRow[0]);
|
||||
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_gps'`);
|
||||
gpsTables.forEach((tableName) => {
|
||||
sqliteService.executeNonQuery(
|
||||
`UPDATE ${tableName} SET time = 0 WHERE time < 0`
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
async getBrokenLeaveEntries() {
|
||||
var instances = await this.getGameLogInstancesTime();
|
||||
var badEntries = [];
|
||||
await sqliteService.execute((dbRow) => {
|
||||
if (typeof dbRow[1] === 'number') {
|
||||
var ref = instances.get(dbRow[0]);
|
||||
if (typeof ref !== 'undefined' && dbRow[1] > ref) {
|
||||
badEntries.push(dbRow[2]);
|
||||
}
|
||||
}
|
||||
}, `SELECT location, time, id FROM gamelog_join_leave WHERE type = 'OnPlayerLeft' AND time > 0`);
|
||||
return badEntries;
|
||||
},
|
||||
|
||||
async fixBrokenLeaveEntries() {
|
||||
var badEntries = await this.getBrokenLeaveEntries();
|
||||
var badEntriesList = '';
|
||||
var count = badEntries.length;
|
||||
badEntries.forEach((entry) => {
|
||||
count--;
|
||||
if (count === 0) {
|
||||
badEntriesList = badEntriesList.concat(entry);
|
||||
} else {
|
||||
badEntriesList = badEntriesList.concat(`${entry}, `);
|
||||
}
|
||||
});
|
||||
|
||||
sqliteService.executeNonQuery(
|
||||
`UPDATE gamelog_join_leave SET time = 0 WHERE id IN (${badEntriesList})`
|
||||
);
|
||||
},
|
||||
|
||||
async fixBrokenGroupInvites() {
|
||||
var notificationTables = [];
|
||||
await sqliteService.execute((dbRow) => {
|
||||
notificationTables.push(dbRow[0]);
|
||||
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_notifications'`);
|
||||
notificationTables.forEach((tableName) => {
|
||||
sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${tableName} WHERE type LIKE '%.%'`
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
async fixBrokenNotifications() {
|
||||
await sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${dbVars.userPrefix}_notifications WHERE (created_at is null or created_at = '')`
|
||||
);
|
||||
},
|
||||
|
||||
async fixBrokenGroupChange() {
|
||||
await sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${dbVars.userPrefix}_notifications WHERE type = 'groupChange' AND created_at < '2024-04-23T03:00:00.000Z'`
|
||||
);
|
||||
},
|
||||
|
||||
async fixCancelFriendRequestTypo() {
|
||||
await sqliteService.executeNonQuery(
|
||||
`UPDATE ${dbVars.userPrefix}_friend_log_history SET type = 'CancelFriendRequest' WHERE type = 'CancelFriendRequst'`
|
||||
);
|
||||
},
|
||||
|
||||
async getBrokenGameLogDisplayNames() {
|
||||
var badEntries = [];
|
||||
await sqliteService.execute((dbRow) => {
|
||||
badEntries.push({
|
||||
id: dbRow[0],
|
||||
displayName: dbRow[1]
|
||||
});
|
||||
}, 'SELECT id, display_name FROM gamelog_join_leave WHERE display_name LIKE "% (%"');
|
||||
return badEntries;
|
||||
},
|
||||
|
||||
async fixBrokenGameLogDisplayNames() {
|
||||
var badEntries = await this.getBrokenGameLogDisplayNames();
|
||||
badEntries.forEach((entry) => {
|
||||
var newDisplayName = entry.displayName.split(' (')[0];
|
||||
sqliteService.executeNonQuery(
|
||||
`UPDATE gamelog_join_leave SET display_name = @new_display_name WHERE id = @id`,
|
||||
{
|
||||
'@new_display_name': newDisplayName,
|
||||
'@id': entry.id
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export { tableFixes };
|
||||
Reference in New Issue
Block a user