diff --git a/html/src/app.js b/html/src/app.js
index 4602bc48..c7ba7318 100644
--- a/html/src/app.js
+++ b/html/src/app.js
@@ -8105,6 +8105,7 @@ speechSynthesis.getVoices();
switch (gameLog.type) {
case 'location-destination':
if (this.isGameRunning) {
+ this.lastLocationReset();
this.lastLocation.location = 'traveling';
this.lastLocationDestination = gameLog.location;
this.lastLocationDestinationTime = Date.parse(gameLog.dt);
@@ -8185,6 +8186,11 @@ speechSynthesis.getVoices();
database.addGamelogJoinLeaveToDatabase(entry);
break;
case 'player-left':
+ if (
+ !this.lastLocation.playerList.has(gameLog.userDisplayName)
+ ) {
+ return;
+ }
var time = 0;
var ref = this.lastLocation.playerList.get(
gameLog.userDisplayName
@@ -10919,6 +10925,7 @@ speechSynthesis.getVoices();
$app.methods.getFriendLog = async function () {
await database.cleanLegendFromFriendLog(); // fix database spam crap
+ await database.fixGameLogTraveling(); // fix past bug with incorrect gameLog locations
var friendLogCurrentArray = await database.getFriendLogCurrent();
for (var friend of friendLogCurrentArray) {
this.friendLog.set(friend.userId, friend);
diff --git a/html/src/repository/database.js b/html/src/repository/database.js
index f63a47f6..256f6f1c 100644
--- a/html/src/repository/database.js
+++ b/html/src/repository/database.js
@@ -1490,6 +1490,49 @@ class Database {
);
sqliteService.executeNonQuery('DELETE FROM cache_avatar');
}
+
+ 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
+ }
+ );
+ });
+ }
}
var self = new Database();