mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Big feed and gameLog table rework
This commit is contained in:
352
html/src/app.js
352
html/src/app.js
@@ -4172,7 +4172,7 @@ speechSynthesis.getVoices();
|
||||
) {
|
||||
var joiningMap = [];
|
||||
var bias = new Date(Date.now() - 120000).toJSON(); // 2 minutes
|
||||
var feedTable = this.feedTable.data;
|
||||
var feedTable = this.feedSessionTable;
|
||||
for (var i = feedTable.length - 1; i > -1; i--) {
|
||||
var ctx = feedTable[i];
|
||||
if (ctx.created_at < bias) {
|
||||
@@ -4197,7 +4197,7 @@ speechSynthesis.getVoices();
|
||||
continue;
|
||||
}
|
||||
var joining = true;
|
||||
var gameLogTable = this.gameLogTable.data;
|
||||
var gameLogTable = this.gameLogSessionTable;
|
||||
for (var k = gameLogTable.length - 1; k > -1; k--) {
|
||||
var gameLogItem = gameLogTable[k];
|
||||
if (
|
||||
@@ -4264,7 +4264,7 @@ speechSynthesis.getVoices();
|
||||
|
||||
$app.methods.updateSharedFeedGameLog = function (forceUpdate) {
|
||||
// Location, OnPlayerJoined, OnPlayerLeft
|
||||
var {data} = this.gameLogTable;
|
||||
var data = this.gameLogSessionTable;
|
||||
var i = data.length;
|
||||
if (i > 0) {
|
||||
if (
|
||||
@@ -4466,7 +4466,7 @@ speechSynthesis.getVoices();
|
||||
|
||||
$app.methods.updateSharedFeedFeedTable = function (forceUpdate) {
|
||||
// GPS, Online, Offline, Status, Avatar
|
||||
var {data} = this.feedTable;
|
||||
var data = this.feedSessionTable;
|
||||
var i = data.length;
|
||||
if (i > 0) {
|
||||
if (
|
||||
@@ -6884,12 +6884,11 @@ speechSynthesis.getVoices();
|
||||
|
||||
// App: Feed
|
||||
|
||||
$app.methods.feedSearch = function (row, filter) {
|
||||
var {value} = filter;
|
||||
$app.methods.feedSearch = function (row) {
|
||||
var value = this.feedTable.search.toUpperCase();
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
value = value.toUpperCase();
|
||||
switch (row.type) {
|
||||
case 'GPS':
|
||||
if (String(row.displayName).toUpperCase().includes(value)) {
|
||||
@@ -6919,6 +6918,9 @@ speechSynthesis.getVoices();
|
||||
if (String(row.displayName).toUpperCase().includes(value)) {
|
||||
return true;
|
||||
}
|
||||
if (String(row.status).toUpperCase().includes(value)) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
String(row.statusDescription).toUpperCase().includes(value)
|
||||
) {
|
||||
@@ -6937,28 +6939,17 @@ speechSynthesis.getVoices();
|
||||
return true;
|
||||
};
|
||||
|
||||
$app.data.tablePageSize = 10;
|
||||
if (configRepository.getInt('VRCX_tablePageSize')) {
|
||||
$app.data.tablePageSize = configRepository.getInt('VRCX_tablePageSize');
|
||||
}
|
||||
|
||||
$app.data.feedTable = {
|
||||
data: [],
|
||||
filters: [
|
||||
{
|
||||
prop: 'type',
|
||||
value: [],
|
||||
filterFn: (row, filter) =>
|
||||
filter.value.some((v) => v === row.type)
|
||||
},
|
||||
{
|
||||
prop: 'displayName',
|
||||
value: '',
|
||||
filterFn: (row, filter) => $app.feedSearch(row, filter)
|
||||
},
|
||||
{
|
||||
prop: 'userId',
|
||||
value: false,
|
||||
filterFn: (row, filter) =>
|
||||
!filter.value ||
|
||||
API.cachedFavoritesByObjectId.has(row.userId)
|
||||
}
|
||||
],
|
||||
search: '',
|
||||
vip: false,
|
||||
loading: false,
|
||||
filter: [],
|
||||
tableProps: {
|
||||
stripe: true,
|
||||
size: 'mini',
|
||||
@@ -6967,20 +6958,58 @@ speechSynthesis.getVoices();
|
||||
order: 'descending'
|
||||
}
|
||||
},
|
||||
pageSize: 10,
|
||||
pageSize: $app.data.tablePageSize,
|
||||
paginationProps: {
|
||||
small: true,
|
||||
layout: 'sizes,prev,pager,next,total',
|
||||
pageSizes: [10, 25, 50, 100]
|
||||
pageSizes: [10, 15, 25, 50, 100]
|
||||
}
|
||||
};
|
||||
|
||||
$app.data.feedSessionTable = [];
|
||||
|
||||
$app.methods.feedTableLookup = async function () {
|
||||
configRepository.setString(
|
||||
'VRCX_feedTableFilters',
|
||||
JSON.stringify(this.feedTable.filter)
|
||||
);
|
||||
configRepository.setBool('VRCX_feedTableVIPFilter', this.feedTable.vip);
|
||||
this.feedTable.loading = true;
|
||||
var vipList = [];
|
||||
if (this.feedTable.vip) {
|
||||
vipList = this.getUserVipList();
|
||||
}
|
||||
this.feedTable.data = await database.lookupFeedDatabase(
|
||||
this.feedTable.search,
|
||||
this.feedTable.filter,
|
||||
vipList
|
||||
);
|
||||
this.feedTable.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.getUserVipList = function () {
|
||||
var vipList = [];
|
||||
API.cachedFavorites.forEach((favorite) => {
|
||||
if (favorite.type === 'friend') {
|
||||
vipList.push(favorite.favoriteId);
|
||||
}
|
||||
});
|
||||
return vipList;
|
||||
};
|
||||
|
||||
API.$on('LOGIN', async function (args) {
|
||||
$app.feedTable.data = [];
|
||||
$app.feedSessionTable = [];
|
||||
$app.friendLogInitStatus = false;
|
||||
await database.initUserTables(args.json.id);
|
||||
$app.feedTable.data = await database.getFeedDatabase();
|
||||
$app.sweepFeed();
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
$app.gameLogTable.data = await database.lookupGameLogDatabase(
|
||||
$app.gameLogTable.search,
|
||||
$app.gameLogTable.filter
|
||||
);
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
$app.feedSessionTable = await database.getFeedDatabase();
|
||||
$app.feedTableLookup();
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
$app.notificationTable.data = await database.getNotifications();
|
||||
if (configRepository.getBool(`friendLogInit_${args.json.id}`)) {
|
||||
@@ -6989,9 +7018,7 @@ speechSynthesis.getVoices();
|
||||
await $app.initFriendLog(args.json.id);
|
||||
}
|
||||
this.getAuth();
|
||||
|
||||
$app.updateSharedFeed(true);
|
||||
|
||||
if ($app.isGameRunning) {
|
||||
$app.loadPlayerList();
|
||||
}
|
||||
@@ -7004,7 +7031,7 @@ speechSynthesis.getVoices();
|
||||
});
|
||||
|
||||
$app.methods.loadPlayerList = function () {
|
||||
var {data} = this.gameLogTable;
|
||||
var data = this.gameLogSessionTable;
|
||||
if (data.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -7180,10 +7207,26 @@ speechSynthesis.getVoices();
|
||||
});
|
||||
|
||||
$app.methods.addFeed = function (feed) {
|
||||
this.queueFeedNoty(feed);
|
||||
this.feedSessionTable.push(feed);
|
||||
if (
|
||||
this.feedTable.filter.length > 0 &&
|
||||
!this.feedTable.filter.includes(feed.type)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.feedTable.vip &&
|
||||
!API.cachedFavoritesByObjectId.has(feed.userId)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (!this.feedSearch(feed)) {
|
||||
return;
|
||||
}
|
||||
this.feedTable.data.push(feed);
|
||||
this.sweepFeed();
|
||||
this.updateSharedFeed(false);
|
||||
this.queueFeedNoty(feed);
|
||||
this.notifyMenu('feed');
|
||||
};
|
||||
|
||||
@@ -7238,18 +7281,22 @@ speechSynthesis.getVoices();
|
||||
$app.methods.sweepFeed = function () {
|
||||
var {data} = this.feedTable;
|
||||
var j = data.length;
|
||||
if (j > 5000) {
|
||||
data.splice(0, j - 5000);
|
||||
if (j > this.maxTableSize) {
|
||||
data.splice(0, j - this.maxTableSize);
|
||||
}
|
||||
var limit = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toJSON();
|
||||
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 1); // 24 hour limit
|
||||
var limit = date.toJSON();
|
||||
var i = 0;
|
||||
while (i < j && data[i].created_at < limit) {
|
||||
var k = this.feedSessionTable.length;
|
||||
while (i < k && this.feedSessionTable[i].created_at < limit) {
|
||||
++i;
|
||||
}
|
||||
if (i === j) {
|
||||
this.feedTable.data = [];
|
||||
if (i === k) {
|
||||
this.feedSessionTable = [];
|
||||
} else if (i) {
|
||||
data.splice(0, i);
|
||||
this.feedSessionTable.splice(0, i);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7276,12 +7323,7 @@ speechSynthesis.getVoices();
|
||||
time
|
||||
};
|
||||
database.addGamelogJoinLeaveToDatabase(entry);
|
||||
this.gameLogTable.data.push(entry);
|
||||
}
|
||||
if (playerList.length > 0) {
|
||||
this.updateSharedFeed(false);
|
||||
this.notifyMenu('gameLog');
|
||||
this.sweepGameLog();
|
||||
this.addGameLog(entry);
|
||||
}
|
||||
if (this.lastLocation.date !== 0) {
|
||||
var timeLocation = new Date().getTime() - this.lastLocation.date;
|
||||
@@ -7328,12 +7370,11 @@ speechSynthesis.getVoices();
|
||||
this.updateDiscord();
|
||||
};
|
||||
|
||||
$app.methods.gameLogSearch = function (row, filter) {
|
||||
var {value} = filter;
|
||||
$app.methods.gameLogSearch = function (row) {
|
||||
var value = this.gameLogTable.search.toUpperCase();
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
value = value.toUpperCase();
|
||||
switch (row.type) {
|
||||
case 'Location':
|
||||
if (String(row.worldName).toUpperCase().includes(value)) {
|
||||
@@ -7358,11 +7399,11 @@ speechSynthesis.getVoices();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case 'AvatarChange':
|
||||
if (String(row.name).toUpperCase().includes(value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// case 'AvatarChange':
|
||||
// if (String(row.name).toUpperCase().includes(value)) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
case 'Event':
|
||||
if (String(row.data).toUpperCase().includes(value)) {
|
||||
return true;
|
||||
@@ -7385,33 +7426,9 @@ speechSynthesis.getVoices();
|
||||
|
||||
$app.data.gameLogTable = {
|
||||
data: [],
|
||||
lastEntryDate: '',
|
||||
filters: [
|
||||
{
|
||||
prop: 'type',
|
||||
value: [],
|
||||
filterFn: (row, filter) =>
|
||||
filter.value.some((v) => v === row.type)
|
||||
},
|
||||
{
|
||||
prop: 'displayName',
|
||||
value: '',
|
||||
filterFn: (row, filter) => $app.gameLogSearch(row, filter)
|
||||
},
|
||||
{
|
||||
prop: 'displayName',
|
||||
value: true,
|
||||
filterFn: (row) =>
|
||||
row.displayName !== API.currentUser.displayName
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
value: true,
|
||||
filterFn: (row) =>
|
||||
row.type !== 'Notification' &&
|
||||
row.type !== 'LocationDestination'
|
||||
}
|
||||
],
|
||||
loading: false,
|
||||
search: '',
|
||||
filter: [],
|
||||
tableProps: {
|
||||
stripe: true,
|
||||
size: 'mini',
|
||||
@@ -7420,14 +7437,54 @@ speechSynthesis.getVoices();
|
||||
order: 'descending'
|
||||
}
|
||||
},
|
||||
pageSize: 10,
|
||||
pageSize: $app.data.tablePageSize,
|
||||
paginationProps: {
|
||||
small: true,
|
||||
layout: 'sizes,prev,pager,next,total',
|
||||
pageSizes: [10, 25, 50, 100]
|
||||
pageSizes: [10, 15, 25, 50, 100]
|
||||
}
|
||||
};
|
||||
|
||||
$app.data.gameLogSessionTable = [];
|
||||
|
||||
$app.methods.gameLogTableLookup = async function () {
|
||||
configRepository.setString(
|
||||
'VRCX_gameLogTableFilters',
|
||||
JSON.stringify(this.gameLogTable.filter)
|
||||
);
|
||||
this.gameLogTable.loading = true;
|
||||
this.gameLogTable.data = await database.lookupGameLogDatabase(
|
||||
this.gameLogTable.search,
|
||||
this.gameLogTable.filter
|
||||
);
|
||||
this.gameLogTable.loading = false;
|
||||
};
|
||||
|
||||
$app.methods.addGameLog = function (entry) {
|
||||
this.gameLogSessionTable.push(entry);
|
||||
if (
|
||||
this.gameLogTable.filter.length > 0 &&
|
||||
!this.gameLogTable.filter.includes(entry.type)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (!this.gameLogSearch(entry)) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
entry.type === 'LocationDestination' ||
|
||||
(entry.userId === API.currentUser.id &&
|
||||
(entry.type === 'OnPlayerJoined' ||
|
||||
entry.type === 'OnPlayerLeft'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this.gameLogTable.data.push(entry);
|
||||
this.sweepGameLog();
|
||||
this.updateSharedFeed(false);
|
||||
this.notifyMenu('gameLog');
|
||||
};
|
||||
|
||||
$app.methods.resetGameLog = async function () {
|
||||
await gameLogService.reset();
|
||||
this.gameLogTable.data = [];
|
||||
@@ -7437,18 +7494,22 @@ speechSynthesis.getVoices();
|
||||
$app.methods.sweepGameLog = function () {
|
||||
var {data} = this.gameLogTable;
|
||||
var j = data.length;
|
||||
if (j > 5000) {
|
||||
data.splice(0, j - 5000);
|
||||
if (j > this.maxTableSize) {
|
||||
data.splice(0, j - this.maxTableSize);
|
||||
}
|
||||
var limit = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toJSON();
|
||||
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 1); // 24 hour limit
|
||||
var limit = date.toJSON();
|
||||
var i = 0;
|
||||
while (i < j && data[i].created_at < limit) {
|
||||
var k = this.gameLogSessionTable.length;
|
||||
while (i < k && this.gameLogSessionTable[i].created_at < limit) {
|
||||
++i;
|
||||
}
|
||||
if (i === j) {
|
||||
this.gameLogTable.data = [];
|
||||
if (i === k) {
|
||||
this.gameLogSessionTable = [];
|
||||
} else if (i) {
|
||||
data.splice(0, i);
|
||||
this.gameLogSessionTable.splice(0, i);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7469,14 +7530,9 @@ speechSynthesis.getVoices();
|
||||
|
||||
$app.methods.getGameLogTable = async function () {
|
||||
await database.initTables();
|
||||
this.gameLogTable.data = await database.getGamelogDatabase();
|
||||
this.sweepGameLog();
|
||||
var length = this.gameLogTable.data.length;
|
||||
if (length > 1) {
|
||||
this.updateGameLog(this.gameLogTable.data[length - 1].created_at);
|
||||
} else {
|
||||
this.updateGameLog('1970-01-01');
|
||||
}
|
||||
this.gameLogSessionTable = await database.getGamelogDatabase();
|
||||
var dateTill = await database.getLastDateGameLogDatabase();
|
||||
this.updateGameLog(dateTill);
|
||||
};
|
||||
|
||||
$app.methods.updateGameLog = async function (dateTill) {
|
||||
@@ -7654,12 +7710,12 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
return;
|
||||
case 'notification':
|
||||
var entry = {
|
||||
created_at: gameLog.dt,
|
||||
type: 'Notification',
|
||||
data: gameLog.json
|
||||
};
|
||||
break;
|
||||
// var entry = {
|
||||
// created_at: gameLog.dt,
|
||||
// type: 'Notification',
|
||||
// data: gameLog.json
|
||||
// };
|
||||
return;
|
||||
case 'event':
|
||||
var entry = {
|
||||
created_at: gameLog.dt,
|
||||
@@ -7671,10 +7727,7 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
if (pushToTable && entry) {
|
||||
this.queueGameLogNoty(entry);
|
||||
this.gameLogTable.data.push(entry);
|
||||
this.updateSharedFeed(false);
|
||||
this.notifyMenu('gameLog');
|
||||
this.sweepGameLog();
|
||||
this.addGameLog(entry);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7741,10 +7794,7 @@ speechSynthesis.getVoices();
|
||||
if (pushToTable) {
|
||||
this.setNowPlaying(entry);
|
||||
this.queueGameLogNoty(entry);
|
||||
this.gameLogTable.data.push(entry);
|
||||
this.updateSharedFeed(false);
|
||||
this.notifyMenu('gameLog');
|
||||
this.sweepGameLog();
|
||||
this.addGameLog(entry);
|
||||
}
|
||||
database.addGamelogVideoPlayToDatabase(entry);
|
||||
}
|
||||
@@ -7811,10 +7861,7 @@ speechSynthesis.getVoices();
|
||||
if (pushToTable) {
|
||||
this.setNowPlaying(entry);
|
||||
this.queueGameLogNoty(entry);
|
||||
this.gameLogTable.data.push(entry);
|
||||
this.updateSharedFeed(false);
|
||||
this.notifyMenu('gameLog');
|
||||
this.sweepGameLog();
|
||||
this.addGameLog(entry);
|
||||
}
|
||||
database.addGamelogVideoPlayToDatabase(entry);
|
||||
}
|
||||
@@ -8636,11 +8683,11 @@ speechSynthesis.getVoices();
|
||||
order: 'descending'
|
||||
}
|
||||
},
|
||||
pageSize: 10,
|
||||
pageSize: $app.data.tablePageSize,
|
||||
paginationProps: {
|
||||
small: true,
|
||||
layout: 'sizes,prev,pager,next,total',
|
||||
pageSizes: [10, 25, 50, 100]
|
||||
pageSizes: [10, 15, 25, 50, 100]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8917,11 +8964,11 @@ speechSynthesis.getVoices();
|
||||
order: 'descending'
|
||||
}
|
||||
},
|
||||
pageSize: 10,
|
||||
pageSize: $app.data.tablePageSize,
|
||||
paginationProps: {
|
||||
small: true,
|
||||
layout: 'sizes,prev,pager,next,total',
|
||||
pageSizes: [10, 25, 50, 100]
|
||||
pageSizes: [10, 15, 25, 50, 100]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9001,11 +9048,11 @@ speechSynthesis.getVoices();
|
||||
order: 'descending'
|
||||
}
|
||||
},
|
||||
pageSize: 10,
|
||||
pageSize: $app.data.tablePageSize,
|
||||
paginationProps: {
|
||||
small: true,
|
||||
layout: 'sizes,prev,pager,next,total',
|
||||
pageSizes: [10, 25, 50, 100]
|
||||
pageSizes: [10, 15, 25, 50, 100]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9141,18 +9188,6 @@ speechSynthesis.getVoices();
|
||||
|
||||
// Save Table Filters
|
||||
$app.methods.saveTableFilters = function () {
|
||||
configRepository.setString(
|
||||
'VRCX_feedTableFilters',
|
||||
JSON.stringify(this.feedTable.filters[0].value)
|
||||
);
|
||||
configRepository.setBool(
|
||||
'VRCX_feedTableVIPFilter',
|
||||
this.feedTable.filters[2].value
|
||||
);
|
||||
configRepository.setString(
|
||||
'VRCX_gameLogTableFilters',
|
||||
JSON.stringify(this.gameLogTable.filters[0].value)
|
||||
);
|
||||
configRepository.setString(
|
||||
'VRCX_friendLogTableFilters',
|
||||
JSON.stringify(this.friendLogTable.filters[0].value)
|
||||
@@ -9167,15 +9202,15 @@ speechSynthesis.getVoices();
|
||||
);
|
||||
};
|
||||
if (configRepository.getString('VRCX_feedTableFilters')) {
|
||||
$app.data.feedTable.filters[0].value = JSON.parse(
|
||||
$app.data.feedTable.filter = JSON.parse(
|
||||
configRepository.getString('VRCX_feedTableFilters')
|
||||
);
|
||||
$app.data.feedTable.filters[2].value = configRepository.getBool(
|
||||
$app.data.feedTable.vip = configRepository.getBool(
|
||||
'VRCX_feedTableVIPFilter'
|
||||
);
|
||||
}
|
||||
if (configRepository.getString('VRCX_gameLogTableFilters')) {
|
||||
$app.data.gameLogTable.filters[0].value = JSON.parse(
|
||||
$app.data.gameLogTable.filter = JSON.parse(
|
||||
configRepository.getString('VRCX_gameLogTableFilters')
|
||||
);
|
||||
}
|
||||
@@ -9349,6 +9384,8 @@ speechSynthesis.getVoices();
|
||||
'VRCX_autoUpdateVRCX'
|
||||
);
|
||||
$app.data.branch = configRepository.getString('VRCX_branch');
|
||||
$app.data.maxTableSize = configRepository.getInt('VRCX_maxTableSize');
|
||||
database.setmaxTableSize($app.data.maxTableSize);
|
||||
$app.methods.saveOpenVROption = function () {
|
||||
configRepository.setBool('openVR', this.openVR);
|
||||
configRepository.setBool('openVRAlways', this.openVRAlways);
|
||||
@@ -9547,6 +9584,11 @@ speechSynthesis.getVoices();
|
||||
if (!configRepository.getString('VRCX_lastVRCXVersion')) {
|
||||
configRepository.setString('VRCX_lastVRCXVersion', appVersion);
|
||||
}
|
||||
if (!configRepository.getInt('VRCX_maxTableSize')) {
|
||||
$app.data.maxTableSize = 1000;
|
||||
configRepository.getInt('VRCX_maxTableSize', $app.data.maxTableSize);
|
||||
database.setmaxTableSize($app.data.maxTableSize);
|
||||
}
|
||||
if (!configRepository.getString('sharedFeedFilters')) {
|
||||
var sharedFeedFilters = {
|
||||
noty: {
|
||||
@@ -10180,6 +10222,38 @@ speechSynthesis.getVoices();
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.promptMaxTableSizeDialog = function () {
|
||||
this.$prompt('Enter a number', 'Max Table Size', {
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: 'Save',
|
||||
cancelButtonText: 'Cancel',
|
||||
inputValue: this.maxTableSize,
|
||||
inputPattern: /\d+$/,
|
||||
inputErrorMessage: 'Valid number is required',
|
||||
callback: (action, instance) => {
|
||||
if (action === 'confirm' && instance.inputValue) {
|
||||
this.maxTableSize = instance.inputValue;
|
||||
configRepository.setString(
|
||||
'VRCX_maxTableSize',
|
||||
this.maxTableSize
|
||||
);
|
||||
database.setmaxTableSize(this.maxTableSize);
|
||||
this.feedTableLookup();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$app.methods.setTablePageSize = function (pageSize) {
|
||||
this.tablePageSize = pageSize;
|
||||
this.feedTable.pageSize = pageSize;
|
||||
this.gameLogTable.pageSize = pageSize;
|
||||
this.friendLogTable.pageSize = pageSize;
|
||||
this.playerModerationTable.pageSize = pageSize;
|
||||
this.notificationTable.pageSize = pageSize;
|
||||
configRepository.setInt('VRCX_tablePageSize', pageSize);
|
||||
};
|
||||
|
||||
// App: Dialog
|
||||
|
||||
var adjustDialogZ = (el) => {
|
||||
|
||||
@@ -70,15 +70,15 @@ html
|
||||
|
||||
//- feed
|
||||
.x-container(v-show="$refs.menu && $refs.menu.activeIndex === 'feed'")
|
||||
data-tables(v-bind="feedTable")
|
||||
data-tables(v-bind="feedTable" v-loading="feedTable.loading")
|
||||
template(#tool)
|
||||
div(style="margin:0 0 10px;display:flex;align-items:center")
|
||||
div(style="flex:none;margin-right:10px")
|
||||
el-tooltip(placement="bottom" content="Filter VIP only" :disabled="hideTooltips")
|
||||
el-switch(v-model="feedTable.filters[2].value" @change="saveTableFilters" active-color="#13ce66")
|
||||
el-select(v-model="feedTable.filters[0].value" @change="saveTableFilters" multiple clearable collapse-tags style="flex:1" placeholder="Filter")
|
||||
el-switch(v-model="feedTable.vip" @change="feedTableLookup" active-color="#13ce66")
|
||||
el-select(v-model="feedTable.filter" @change="feedTableLookup" multiple clearable collapse-tags style="flex:1" placeholder="Filter")
|
||||
el-option(v-once v-for="type in ['GPS', 'Online', 'Offline', 'Status', 'Avatar']" :key="type" :label="type" :value="type")
|
||||
el-input(v-model="feedTable.filters[1].value" placeholder="Search" style="flex:none;width:150px;margin:0 10px")
|
||||
el-input(v-model="feedTable.search" placeholder="Search" @keyup.native.13="feedTableLookup" @change="feedTableLookup" clearable style="flex:none;width:150px;margin:0 10px")
|
||||
el-tooltip(placement="bottom" content="Clear feed" :disabled="hideTooltips")
|
||||
el-button(type="default" @click="clearFeed()" icon="el-icon-delete" circle style="flex:none")
|
||||
el-table-column(type="expand" width="20")
|
||||
@@ -180,12 +180,12 @@ html
|
||||
|
||||
//- gameLog
|
||||
.x-container(v-show="$refs.menu && $refs.menu.activeIndex === 'gameLog'")
|
||||
data-tables(v-bind="gameLogTable")
|
||||
data-tables(v-bind="gameLogTable" v-loading="gameLogTable.loading")
|
||||
template(#tool)
|
||||
div(style="margin:0 0 10px;display:flex;align-items:center")
|
||||
el-select(v-model="gameLogTable.filters[0].value" @change="saveTableFilters" multiple clearable collapse-tags style="flex:1" placeholder="Filter")
|
||||
el-select(v-model="gameLogTable.filter" @change="gameLogTableLookup" multiple clearable collapse-tags style="flex:1" placeholder="Filter")
|
||||
el-option(v-once v-for="type in ['Location', 'OnPlayerJoined', 'OnPlayerLeft', 'PortalSpawn', 'AvatarChange', 'Event', 'VideoPlay']" :key="type" :label="type" :value="type")
|
||||
el-input(v-model="gameLogTable.filters[1].value" placeholder="Search" style="flex:none;width:150px;margin:0 10px")
|
||||
el-input(v-model="gameLogTable.search" placeholder="Search" @keyup.native.13="gameLogTableLookup" @change="gameLogTableLookup" clearable style="flex:none;width:150px;margin:0 10px")
|
||||
//- el-tooltip(placement="bottom" content="Reload game log" :disabled="hideTooltips")
|
||||
//- el-button(type="default" @click="resetGameLog" icon="el-icon-refresh" circle style="flex:none")
|
||||
el-table-column(label="Date" prop="created_at" sortable="custom" width="90")
|
||||
@@ -724,7 +724,7 @@ html
|
||||
span.name Support
|
||||
span.extra https://vrcx.pypy.moe/discord
|
||||
div.options-container
|
||||
span.sub-header VRCX Updater
|
||||
span.header VRCX Updater
|
||||
div.options-container-item
|
||||
el-button(size="small" icon="el-icon-upload" @click="showVRCXUpdateDialog()") Check for update
|
||||
div.options-container-item
|
||||
@@ -749,6 +749,14 @@ html
|
||||
div.options-container-item
|
||||
span.name Disable Tooltips
|
||||
el-switch(v-model="hideTooltips" @change="saveOpenVROption")
|
||||
div.options-container-item
|
||||
el-button(size="small" icon="el-icon-notebook-1" @click="promptMaxTableSizeDialog") Table Max Size
|
||||
div.options-container-item
|
||||
el-dropdown(@click.native.stop trigger="click" size="small")
|
||||
el-button(size="mini")
|
||||
span Page Size: {{ tablePageSize }} #[i.el-icon-arrow-down.el-icon--right]
|
||||
el-dropdown-menu(#default="dropdown")
|
||||
el-dropdown-item(v-for="(number) in [10, 15, 25, 50, 100]" v-text="number" @click.native="setTablePageSize(number)")
|
||||
div.options-container
|
||||
span.header Side Panel
|
||||
br
|
||||
@@ -815,6 +823,8 @@ html
|
||||
span * Only works when VRChat is running.
|
||||
div.options-container-item
|
||||
span.name Enable
|
||||
el-tooltip(placement="top" style="margin-left:5px" content="Recommended to disable Rich Presence in VRChat config.json below to stop it from conflicting")
|
||||
i.el-icon-warning
|
||||
el-switch(v-model="discordActive" @change="saveDiscordOption")
|
||||
div.options-container-item
|
||||
span.name Instance type/player count
|
||||
@@ -903,7 +913,7 @@ html
|
||||
div.options-container-item
|
||||
span.name TTS Voice
|
||||
el-dropdown(@command="(voice) => changeTTSVoice(voice)" trigger="click" size="small")
|
||||
el-button(size="mini" :disabled="!notificationTTS")
|
||||
el-button(size="mini" :disabled="notificationTTS === 'Never'")
|
||||
span {{ TTSvoices[notificationTTSVoice].name }} #[i.el-icon-arrow-down.el-icon--right]
|
||||
el-dropdown-menu(#default="dropdown")
|
||||
el-dropdown-item(v-if="voice" v-for="(voice, index) in TTSvoices" :key="index" v-text="voice.name" :command="index")
|
||||
@@ -986,7 +996,7 @@ html
|
||||
div.options-container-item
|
||||
el-button(size="small" icon="el-icon-tickets" @click="showConsole") Show Console
|
||||
div.options-container
|
||||
span.header SQLite Table Size
|
||||
span.sub-header SQLite Table Size
|
||||
div.options-container-item
|
||||
el-button(size="small" icon="el-icon-refresh" @click="getSqliteTableSizes") Refresh
|
||||
div.options-container-item
|
||||
@@ -1412,7 +1422,7 @@ html
|
||||
el-tooltip(placement="top" content="Refresh player count" :disabled="hideTooltips")
|
||||
el-button(@click="refreshInstancePlayerCount(room.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle)
|
||||
span(v-if="room.occupants" style="margin-left:5px") {{ room.occupants }} #[template(v-if="room.friendCount > 0") ({{ room.friendCount }})]
|
||||
.x-friend-list(style="margin:10px 0" v-if="room.$location.userId || room.users.length")
|
||||
.x-friend-list(style="margin:10px 0;max-height:unset" v-if="room.$location.userId || room.users.length")
|
||||
.x-friend-item(v-if="room.$location.userId" @click="showUserDialog(room.$location.userId)" class="x-friend-item-border")
|
||||
template(v-if="room.$location.user")
|
||||
.avatar(:class="userStatusClass(room.$location.user)")
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
import sqliteService from '../service/sqlite.js';
|
||||
|
||||
class Database {
|
||||
setmaxTableSize(limit) {
|
||||
Database.maxTableSize = limit;
|
||||
}
|
||||
|
||||
async initUserTables(userId) {
|
||||
Database.userId = userId.replaceAll('-', '').replaceAll('_', '');
|
||||
Database.userId = userId;
|
||||
Database.userPrefix = userId.replaceAll('-', '').replaceAll('_', '');
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_feed_gps (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, location TEXT, world_name TEXT, previous_location TEXT, time INTEGER)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_gps (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, location TEXT, world_name TEXT, previous_location TEXT, time INTEGER)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_feed_status (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, status TEXT, status_description TEXT, previous_status TEXT, previous_status_description TEXT)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_status (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, status TEXT, status_description TEXT, previous_status TEXT, previous_status_description TEXT)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_feed_avatar (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, owner_id TEXT, avatar_name TEXT, current_avatar_image_url TEXT, current_avatar_thumbnail_image_url TEXT, previous_current_avatar_image_url TEXT, previous_current_avatar_thumbnail_image_url TEXT)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_avatar (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, owner_id TEXT, avatar_name TEXT, current_avatar_image_url TEXT, current_avatar_thumbnail_image_url TEXT, previous_current_avatar_image_url TEXT, previous_current_avatar_thumbnail_image_url TEXT)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_feed_online_offline (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, type TEXT, location TEXT, world_name TEXT, time INTEGER)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_online_offline (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, type TEXT, location TEXT, world_name TEXT, time INTEGER)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_friend_log_current (user_id TEXT PRIMARY KEY, display_name TEXT, trust_level TEXT)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_friend_log_current (user_id TEXT PRIMARY KEY, display_name TEXT, trust_level TEXT)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_friend_log_history (id INTEGER PRIMARY KEY, created_at TEXT, type TEXT, user_id TEXT, display_name TEXT, previous_display_name TEXT, trust_level TEXT, previous_trust_level TEXT)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_friend_log_history (id INTEGER PRIMARY KEY, created_at TEXT, type TEXT, user_id TEXT, display_name TEXT, previous_display_name TEXT, trust_level TEXT, previous_trust_level TEXT)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userId}_notifications (id TEXT PRIMARY KEY, created_at TEXT, type TEXT, sender_user_id TEXT, sender_username TEXT, receiver_user_id TEXT, message TEXT, world_id TEXT, world_name TEXT, image_url TEXT, invite_message TEXT, request_message TEXT, response_message TEXT, expired INTEGER)`
|
||||
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_notifications (id TEXT PRIMARY KEY, created_at TEXT, type TEXT, sender_user_id TEXT, sender_username TEXT, receiver_user_id TEXT, message TEXT, world_id TEXT, world_name TEXT, image_url TEXT, invite_message TEXT, request_message TEXT, response_message TEXT, expired INTEGER)`
|
||||
);
|
||||
await sqliteService.executeNonQuery(
|
||||
`CREATE TABLE IF NOT EXISTS memos (user_id TEXT PRIMARY KEY, edited_at TEXT, memo TEXT)`
|
||||
@@ -50,7 +55,7 @@ class Database {
|
||||
async getFeedDatabase() {
|
||||
var feedDatabase = [];
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 3); // 3 day limit
|
||||
date.setDate(date.getDate() - 1); // 24 hour limit
|
||||
var dateOffset = date.toJSON();
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
@@ -65,7 +70,7 @@ class Database {
|
||||
time: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_feed_gps WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -79,7 +84,7 @@ class Database {
|
||||
previousStatusDescription: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_feed_status WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_status WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -95,7 +100,7 @@ class Database {
|
||||
previousCurrentAvatarThumbnailImageUrl: dbRow[9]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_feed_avatar WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_avatar WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -108,7 +113,7 @@ class Database {
|
||||
time: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_feed_online_offline WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
var compareByCreatedAt = function (a, b) {
|
||||
var A = a.created_at;
|
||||
var B = b.created_at;
|
||||
@@ -121,7 +126,6 @@ class Database {
|
||||
return 0;
|
||||
};
|
||||
feedDatabase.sort(compareByCreatedAt);
|
||||
feedDatabase.splice(0, feedDatabase.length - 5000);
|
||||
return feedDatabase;
|
||||
}
|
||||
|
||||
@@ -175,13 +179,13 @@ class Database {
|
||||
trustLevel: dbRow[2]
|
||||
};
|
||||
friendLogCurrent.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_friend_log_current`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_friend_log_current`);
|
||||
return friendLogCurrent;
|
||||
}
|
||||
|
||||
setFriendLogCurrent(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR REPLACE INTO ${Database.userId}_friend_log_current (user_id, display_name, trust_level) VALUES (@user_id, @display_name, @trust_level)`,
|
||||
`INSERT OR REPLACE INTO ${Database.userPrefix}_friend_log_current (user_id, display_name, trust_level) VALUES (@user_id, @display_name, @trust_level)`,
|
||||
{
|
||||
'@user_id': entry.userId,
|
||||
'@display_name': entry.displayName,
|
||||
@@ -209,13 +213,13 @@ class Database {
|
||||
}
|
||||
sqlValues = sqlValues.slice(0, -2);
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR REPLACE INTO ${Database.userId}_friend_log_current (user_id, display_name, trust_level) VALUES ${sqlValues}`
|
||||
`INSERT OR REPLACE INTO ${Database.userPrefix}_friend_log_current (user_id, display_name, trust_level) VALUES ${sqlValues}`
|
||||
);
|
||||
}
|
||||
|
||||
deleteFriendLogCurrent(userId) {
|
||||
sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${Database.userId}_friend_log_current WHERE user_id = @user_id`,
|
||||
`DELETE FROM ${Database.userPrefix}_friend_log_current WHERE user_id = @user_id`,
|
||||
{
|
||||
'@user_id': userId
|
||||
}
|
||||
@@ -239,13 +243,13 @@ class Database {
|
||||
row.previousTrustLevel = dbRow[7];
|
||||
}
|
||||
friendLogHistory.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_friend_log_history LIMIT 10000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_friend_log_history`);
|
||||
return friendLogHistory;
|
||||
}
|
||||
|
||||
addFriendLogHistory(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_friend_log_history (created_at, type, user_id, display_name, previous_display_name, trust_level, previous_trust_level) VALUES (@created_at, @type, @user_id, @display_name, @previous_display_name, @trust_level, @previous_trust_level)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_friend_log_history (created_at, type, user_id, display_name, previous_display_name, trust_level, previous_trust_level) VALUES (@created_at, @type, @user_id, @display_name, @previous_display_name, @trust_level, @previous_trust_level)`,
|
||||
{
|
||||
'@created_at': entry.created_at,
|
||||
'@type': entry.type,
|
||||
@@ -295,13 +299,13 @@ class Database {
|
||||
// sqlValues `('${line.created_at}', '${line.type}', '${line.userId}', '${line.displayName}', '${line.previousDisplayName}', '${line.trustLevel}', '${line.previousTrustLevel}'), `
|
||||
}
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_friend_log_history (created_at, type, user_id, display_name, previous_display_name, trust_level, previous_trust_level) VALUES ${sqlValues}`
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_friend_log_history (created_at, type, user_id, display_name, previous_display_name, trust_level, previous_trust_level) VALUES ${sqlValues}`
|
||||
);
|
||||
}
|
||||
|
||||
deleteFriendLogHistory(rowId) {
|
||||
sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${Database.userId}_friend_log_history WHERE id = @row_id`,
|
||||
`DELETE FROM ${Database.userPrefix}_friend_log_history WHERE id = @row_id`,
|
||||
{
|
||||
'@row_id': rowId
|
||||
}
|
||||
@@ -310,7 +314,7 @@ class Database {
|
||||
|
||||
addGPSToDatabase(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_feed_gps (created_at, user_id, display_name, location, world_name, previous_location, time) VALUES (@created_at, @user_id, @display_name, @location, @world_name, @previous_location, @time)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_gps (created_at, user_id, display_name, location, world_name, previous_location, time) VALUES (@created_at, @user_id, @display_name, @location, @world_name, @previous_location, @time)`,
|
||||
{
|
||||
'@created_at': entry.created_at,
|
||||
'@user_id': entry.userId,
|
||||
@@ -325,7 +329,7 @@ class Database {
|
||||
|
||||
addStatusToDatabase(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_feed_status (created_at, user_id, display_name, status, status_description, previous_status, previous_status_description) VALUES (@created_at, @user_id, @display_name, @status, @status_description, @previous_status, @previous_status_description)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_status (created_at, user_id, display_name, status, status_description, previous_status, previous_status_description) VALUES (@created_at, @user_id, @display_name, @status, @status_description, @previous_status, @previous_status_description)`,
|
||||
{
|
||||
'@created_at': entry.created_at,
|
||||
'@user_id': entry.userId,
|
||||
@@ -340,7 +344,7 @@ class Database {
|
||||
|
||||
addAvatarToDatabase(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_feed_avatar (created_at, user_id, display_name, owner_id, avatar_name, current_avatar_image_url, current_avatar_thumbnail_image_url, previous_current_avatar_image_url, previous_current_avatar_thumbnail_image_url) VALUES (@created_at, @user_id, @display_name, @owner_id, @avatar_name, @current_avatar_image_url, @current_avatar_thumbnail_image_url, @previous_current_avatar_image_url, @previous_current_avatar_thumbnail_image_url)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_avatar (created_at, user_id, display_name, owner_id, avatar_name, current_avatar_image_url, current_avatar_thumbnail_image_url, previous_current_avatar_image_url, previous_current_avatar_thumbnail_image_url) VALUES (@created_at, @user_id, @display_name, @owner_id, @avatar_name, @current_avatar_image_url, @current_avatar_thumbnail_image_url, @previous_current_avatar_image_url, @previous_current_avatar_thumbnail_image_url)`,
|
||||
{
|
||||
'@created_at': entry.created_at,
|
||||
'@user_id': entry.userId,
|
||||
@@ -360,7 +364,7 @@ class Database {
|
||||
|
||||
addOnlineOfflineToDatabase(entry) {
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_feed_online_offline (created_at, user_id, display_name, type, location, world_name, time) VALUES (@created_at, @user_id, @display_name, @type, @location, @world_name, @time)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_online_offline (created_at, user_id, display_name, type, location, world_name, time) VALUES (@created_at, @user_id, @display_name, @type, @location, @world_name, @time)`,
|
||||
{
|
||||
'@created_at': entry.created_at,
|
||||
'@user_id': entry.userId,
|
||||
@@ -376,7 +380,7 @@ class Database {
|
||||
async getGamelogDatabase() {
|
||||
var gamelogDatabase = [];
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 7); // 7 day limit
|
||||
date.setDate(date.getDate() - 1); // 24 hour limit
|
||||
var dateOffset = date.toJSON();
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
@@ -389,7 +393,7 @@ class Database {
|
||||
time: dbRow[5]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_location WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM gamelog_location WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -401,7 +405,7 @@ class Database {
|
||||
time: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_join_leave WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM gamelog_join_leave WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -414,7 +418,7 @@ class Database {
|
||||
worldName: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_portal_spawn WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM gamelog_portal_spawn WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -428,7 +432,7 @@ class Database {
|
||||
userId: dbRow[7]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_video_play WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM gamelog_video_play WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
@@ -437,7 +441,7 @@ class Database {
|
||||
data: dbRow[2]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_event WHERE created_at >= date('${dateOffset}') LIMIT 5000`);
|
||||
}, `SELECT * FROM gamelog_event WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
|
||||
var compareByCreatedAt = function (a, b) {
|
||||
var A = a.created_at;
|
||||
var B = b.created_at;
|
||||
@@ -449,7 +453,6 @@ class Database {
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
gamelogDatabase.splice(0, gamelogDatabase.length - 5000);
|
||||
gamelogDatabase.sort(compareByCreatedAt);
|
||||
return gamelogDatabase;
|
||||
}
|
||||
@@ -555,7 +558,7 @@ class Database {
|
||||
row.$isExpired = true;
|
||||
}
|
||||
notifications.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userId}_notifications LIMIT 5000`);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_notifications ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
return notifications;
|
||||
}
|
||||
|
||||
@@ -584,7 +587,7 @@ class Database {
|
||||
expired = 1;
|
||||
}
|
||||
sqliteService.executeNonQuery(
|
||||
`INSERT OR IGNORE INTO ${Database.userId}_notifications (id, created_at, type, sender_user_id, sender_username, receiver_user_id, message, world_id, world_name, image_url, invite_message, request_message, response_message, expired) VALUES (@id, @created_at, @type, @sender_user_id, @sender_username, @receiver_user_id, @message, @world_id, @world_name, @image_url, @invite_message, @request_message, @response_message, @expired)`,
|
||||
`INSERT OR IGNORE INTO ${Database.userPrefix}_notifications (id, created_at, type, sender_user_id, sender_username, receiver_user_id, message, world_id, world_name, image_url, invite_message, request_message, response_message, expired) VALUES (@id, @created_at, @type, @sender_user_id, @sender_username, @receiver_user_id, @message, @world_id, @world_name, @image_url, @invite_message, @request_message, @response_message, @expired)`,
|
||||
{
|
||||
'@id': entry.id,
|
||||
'@created_at': entry.created_at,
|
||||
@@ -606,7 +609,7 @@ class Database {
|
||||
|
||||
deleteNotification(rowId) {
|
||||
sqliteService.executeNonQuery(
|
||||
`DELETE FROM ${Database.userId}_notifications WHERE id = @row_id`,
|
||||
`DELETE FROM ${Database.userPrefix}_notifications WHERE id = @row_id`,
|
||||
{
|
||||
'@row_id': rowId
|
||||
}
|
||||
@@ -619,7 +622,7 @@ class Database {
|
||||
expired = 1;
|
||||
}
|
||||
sqliteService.executeNonQuery(
|
||||
`UPDATE ${Database.userId}_notifications SET expired = @expired WHERE id = @id`,
|
||||
`UPDATE ${Database.userPrefix}_notifications SET expired = @expired WHERE id = @id`,
|
||||
{
|
||||
'@id': entry.id,
|
||||
'@expired': expired
|
||||
@@ -631,7 +634,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_feed_gps`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_feed_gps`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -639,7 +642,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_feed_status`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_feed_status`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -647,7 +650,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_feed_avatar`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_feed_avatar`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -655,7 +658,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_feed_online_offline`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_feed_online_offline`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -663,7 +666,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_friend_log_history`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_friend_log_history`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -671,7 +674,7 @@ class Database {
|
||||
var size = 0;
|
||||
await sqliteService.execute((row) => {
|
||||
size = row[0];
|
||||
}, `SELECT COUNT(*) FROM ${Database.userId}_notifications`);
|
||||
}, `SELECT COUNT(*) FROM ${Database.userPrefix}_notifications`);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -805,6 +808,301 @@ class Database {
|
||||
}, `SELECT time FROM gamelog_join_leave WHERE (type = 'OnPlayerLeft') AND (user_id = '${userId}' OR display_name = '${displayName}')`);
|
||||
return ref;
|
||||
}
|
||||
|
||||
async lookupFeedDatabase(search, filters, vipList) {
|
||||
var search = search.replaceAll("'", "''");
|
||||
var vipQuery = '';
|
||||
if (vipList.length > 0) {
|
||||
vipQuery = 'AND user_id IN (';
|
||||
vipList.forEach((vip, i) => {
|
||||
vipQuery += `'${vip.replaceAll("'", "''")}'`;
|
||||
if (i < vipList.length - 1) {
|
||||
vipQuery += ', ';
|
||||
}
|
||||
});
|
||||
vipQuery += ')';
|
||||
}
|
||||
var gps = true;
|
||||
var status = true;
|
||||
var avatar = true;
|
||||
var online = true;
|
||||
var offline = true;
|
||||
if (filters.length > 0) {
|
||||
gps = false;
|
||||
status = false;
|
||||
avatar = false;
|
||||
online = false;
|
||||
offline = false;
|
||||
filters.forEach((filter) => {
|
||||
switch (filter) {
|
||||
case 'GPS':
|
||||
gps = true;
|
||||
break;
|
||||
case 'Status':
|
||||
status = true;
|
||||
break;
|
||||
case 'Avatar':
|
||||
avatar = true;
|
||||
break;
|
||||
case 'Online':
|
||||
online = true;
|
||||
break;
|
||||
case 'Offline':
|
||||
offline = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
var feedDatabase = [];
|
||||
if (gps) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
userId: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
type: 'GPS',
|
||||
location: dbRow[4],
|
||||
worldName: dbRow[5],
|
||||
previousLocation: dbRow[6],
|
||||
time: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (status) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
userId: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
type: 'Status',
|
||||
status: dbRow[4],
|
||||
statusDescription: dbRow[5],
|
||||
previousStatus: dbRow[6],
|
||||
previousStatusDescription: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_status WHERE (display_name LIKE '%${search}%' OR status LIKE '%${search}%' OR status_description LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (avatar) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
userId: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
type: 'Avatar',
|
||||
ownerId: dbRow[4],
|
||||
avatarName: dbRow[5],
|
||||
currentAvatarImageUrl: dbRow[6],
|
||||
currentAvatarThumbnailImageUrl: dbRow[7],
|
||||
previousCurrentAvatarImageUrl: dbRow[8],
|
||||
previousCurrentAvatarThumbnailImageUrl: dbRow[9]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_avatar WHERE (display_name LIKE '%${search}%' OR avatar_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (online || offline) {
|
||||
var query = '';
|
||||
if (!online || !offline) {
|
||||
if (online) {
|
||||
query = "AND type = 'Online'";
|
||||
} else if (offline) {
|
||||
query = "AND type = 'Offline'";
|
||||
}
|
||||
}
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
userId: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
type: dbRow[4],
|
||||
location: dbRow[5],
|
||||
worldName: dbRow[6],
|
||||
time: dbRow[7]
|
||||
};
|
||||
feedDatabase.unshift(row);
|
||||
}, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE ((display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
var compareByCreatedAt = function (a, b) {
|
||||
var A = a.created_at;
|
||||
var B = b.created_at;
|
||||
if (A < B) {
|
||||
return -1;
|
||||
}
|
||||
if (A > B) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
feedDatabase.sort(compareByCreatedAt);
|
||||
feedDatabase.splice(0, feedDatabase.length - Database.maxTableSize);
|
||||
return feedDatabase;
|
||||
}
|
||||
|
||||
async lookupGameLogDatabase(search, filters) {
|
||||
var search = search.replaceAll("'", "''");
|
||||
var location = true;
|
||||
var onplayerjoined = true;
|
||||
var onplayerleft = true;
|
||||
var portalspawn = true;
|
||||
var msgevent = true;
|
||||
var videoplay = true;
|
||||
if (filters.length > 0) {
|
||||
location = false;
|
||||
onplayerjoined = false;
|
||||
onplayerleft = false;
|
||||
portalspawn = false;
|
||||
msgevent = false;
|
||||
videoplay = false;
|
||||
filters.forEach((filter) => {
|
||||
switch (filter) {
|
||||
case 'Location':
|
||||
location = true;
|
||||
break;
|
||||
case 'OnPlayerJoined':
|
||||
onplayerjoined = true;
|
||||
break;
|
||||
case 'OnPlayerLeft':
|
||||
onplayerleft = true;
|
||||
break;
|
||||
case 'PortalSpawn':
|
||||
portalspawn = true;
|
||||
break;
|
||||
case 'Event':
|
||||
msgevent = true;
|
||||
break;
|
||||
case 'VideoPlay':
|
||||
videoplay = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
var gamelogDatabase = [];
|
||||
if (location) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'Location',
|
||||
location: dbRow[2],
|
||||
worldId: dbRow[3],
|
||||
worldName: dbRow[4],
|
||||
time: dbRow[5]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (onplayerjoined || onplayerleft) {
|
||||
var query = '';
|
||||
if (!onplayerjoined || !onplayerleft) {
|
||||
if (onplayerjoined) {
|
||||
query = "AND type = 'OnPlayerJoined'";
|
||||
} else if (onplayerleft) {
|
||||
query = "AND type = 'OnPlayerLeft'";
|
||||
}
|
||||
}
|
||||
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]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_join_leave WHERE (display_name LIKE '%${search}%' AND user_id != '${Database.userId}') ${query} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (portalspawn) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'PortalSpawn',
|
||||
displayName: dbRow[2],
|
||||
location: dbRow[3],
|
||||
userId: dbRow[4],
|
||||
instanceId: dbRow[5],
|
||||
worldName: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_portal_spawn WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (msgevent) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'Event',
|
||||
data: dbRow[2]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_event WHERE data LIKE '%${search}%' ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
if (videoplay) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'VideoPlay',
|
||||
videoUrl: dbRow[2],
|
||||
videoName: dbRow[3],
|
||||
videoId: dbRow[4],
|
||||
location: dbRow[5],
|
||||
displayName: dbRow[6],
|
||||
userId: dbRow[7]
|
||||
};
|
||||
gamelogDatabase.unshift(row);
|
||||
}, `SELECT * FROM gamelog_video_play WHERE video_url LIKE '%${search}%' OR video_name LIKE '%${search}%' OR display_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
|
||||
}
|
||||
var compareByCreatedAt = function (a, b) {
|
||||
var A = a.created_at;
|
||||
var B = b.created_at;
|
||||
if (A < B) {
|
||||
return -1;
|
||||
}
|
||||
if (A > B) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
gamelogDatabase.sort(compareByCreatedAt);
|
||||
gamelogDatabase.splice(
|
||||
0,
|
||||
gamelogDatabase.length - Database.maxTableSize
|
||||
);
|
||||
return gamelogDatabase;
|
||||
}
|
||||
|
||||
async getLastDateGameLogDatabase() {
|
||||
var gamelogDatabase = [];
|
||||
var date = '1970-01-01';
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gamelogDatabase.unshift(dbRow[0]);
|
||||
}, 'SELECT created_at FROM gamelog_location ORDER BY id DESC LIMIT 1');
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gamelogDatabase.unshift(dbRow[0]);
|
||||
}, 'SELECT created_at FROM gamelog_join_leave ORDER BY id DESC LIMIT 1');
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gamelogDatabase.unshift(dbRow[0]);
|
||||
}, 'SELECT created_at FROM gamelog_portal_spawn ORDER BY id DESC LIMIT 1');
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gamelogDatabase.unshift(dbRow[0]);
|
||||
}, 'SELECT created_at FROM gamelog_event ORDER BY id DESC LIMIT 1');
|
||||
await sqliteService.execute((dbRow) => {
|
||||
gamelogDatabase.unshift(dbRow[0]);
|
||||
}, 'SELECT created_at FROM gamelog_video_play ORDER BY id DESC LIMIT 1');
|
||||
if (gamelogDatabase.length > 0) {
|
||||
gamelogDatabase.sort();
|
||||
date = gamelogDatabase[gamelogDatabase.length - 1];
|
||||
}
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
var self = new Database();
|
||||
|
||||
Reference in New Issue
Block a user