diff --git a/html/src/app.js b/html/src/app.js
index 315cfdca..0ccc1cac 100644
--- a/html/src/app.js
+++ b/html/src/app.js
@@ -566,9 +566,9 @@ speechSynthesis.getVoices();
//
...json
};
- if ($app.lastLocation.playerList.has(json.displayName)) {
+ if ($app.lastLocation.playerList.has(json.id)) {
// update $location_at from instance join time
- var player = $app.lastLocation.playerList.get(json.displayName);
+ var player = $app.lastLocation.playerList.get(json.id);
ref.$location_at = player.joinTime;
ref.$online_for = player.joinTime;
}
@@ -5428,17 +5428,14 @@ speechSynthesis.getVoices();
joinTime: Date.parse(ctx.created_at),
lastAvatar: ''
};
- this.lastLocation.playerList.set(ctx.displayName, userMap);
+ this.lastLocation.playerList.set(ctx.userId, userMap);
if (this.friends.has(ctx.userId)) {
- this.lastLocation.friendList.set(
- ctx.displayName,
- userMap
- );
+ this.lastLocation.friendList.set(ctx.userId, userMap);
}
}
if (ctx.type === 'OnPlayerLeft') {
- this.lastLocation.playerList.delete(ctx.displayName);
- this.lastLocation.friendList.delete(ctx.displayName);
+ this.lastLocation.playerList.delete(ctx.userId);
+ this.lastLocation.friendList.delete(ctx.userId);
}
}
this.lastLocation.playerList.forEach((ref1) => {
@@ -5743,7 +5740,6 @@ speechSynthesis.getVoices();
};
database.updateGamelogLocationTimeToDatabase(update);
}
- this.gameLogApiLoggingEnabled = false;
this.lastLocationDestination = '';
this.lastLocationDestinationTime = 0;
this.lastLocation = {
@@ -5779,17 +5775,7 @@ speechSynthesis.getVoices();
$app.data.lastLocationDestinationTime = 0;
$app.methods.silentSearchUser = function (displayName) {
- var playerListRef = this.lastLocation.playerList.get(displayName);
- if (
- !this.gameLogApiLoggingEnabled ||
- !playerListRef ||
- playerListRef.userId
- ) {
- return;
- }
- if (this.debugGameLog) {
- console.log('Searching for userId for:', displayName);
- }
+ console.log('Searching for userId for:', displayName);
var params = {
n: 5,
offset: 0,
@@ -9318,7 +9304,7 @@ speechSynthesis.getVoices();
API.getUser(args.params);
}
var inCurrentWorld = false;
- if (this.lastLocation.playerList.has(D.ref.displayName)) {
+ if (this.lastLocation.playerList.has(D.ref.id)) {
inCurrentWorld = true;
}
if (userId !== API.currentUser.id) {
@@ -9450,7 +9436,7 @@ speechSynthesis.getVoices();
for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them
var addUser = !users.some(function (user) {
- return friend.displayName === user.displayName;
+ return friend.userId === user.id;
});
if (addUser) {
var ref = API.cachedUsers.get(friend.userId);
@@ -9538,26 +9524,11 @@ speechSynthesis.getVoices();
API.$on('USER:APPLY', function (ref) {
// add user ref to playerList, friendList, photonLobby, photonLobbyCurrent
- if ($app.lastLocation.playerList.has(ref.displayName)) {
- var playerListRef = $app.lastLocation.playerList.get(
- ref.displayName
- );
- if (!playerListRef.userId) {
- playerListRef.userId = ref.id;
- $app.lastLocation.playerList.set(
- ref.displayName,
- playerListRef
- );
- if ($app.lastLocation.friendList.has(ref.displayName)) {
- $app.lastLocation.friendList.set(
- ref.displayName,
- playerListRef
- );
- }
- }
+ var playerListRef = $app.lastLocation.playerList.get(ref.id);
+ if (playerListRef) {
// add/remove friends from lastLocation.friendList
if (
- !$app.lastLocation.friendList.has(ref.displayName) &&
+ !$app.lastLocation.friendList.has(ref.id) &&
$app.friends.has(ref.id)
) {
var userMap = {
@@ -9565,13 +9536,13 @@ speechSynthesis.getVoices();
userId: ref.id,
joinTime: playerListRef.joinTime
};
- $app.lastLocation.friendList.set(ref.displayName, userMap);
+ $app.lastLocation.friendList.set(ref.id, userMap);
}
if (
- $app.lastLocation.friendList.has(ref.displayName) &&
+ $app.lastLocation.friendList.has(ref.id) &&
!$app.friends.has(ref.id)
) {
- $app.lastLocation.friendList.delete(ref.displayName);
+ $app.lastLocation.friendList.delete(ref.id);
}
$app.photonLobby.forEach((ref1, id) => {
if (
@@ -9699,10 +9670,7 @@ speechSynthesis.getVoices();
var playersInInstance = this.lastLocation.playerList;
if (playersInInstance.size > 0) {
var ref = API.cachedUsers.get(API.currentUser.id);
- if (
- typeof ref !== 'undefined' &&
- playersInInstance.has(ref.displayName)
- ) {
+ if (typeof ref !== 'undefined' && playersInInstance.has(ref.id)) {
pushUser(ref);
}
for (var player of playersInInstance.values()) {
@@ -9719,7 +9687,7 @@ speechSynthesis.getVoices();
pushUser(ref);
} else {
var { joinTime } = this.lastLocation.playerList.get(
- player.displayName
+ player.userId
);
if (!joinTime) {
joinTime = Date.now();
@@ -10801,7 +10769,7 @@ speechSynthesis.getVoices();
for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them
var addUser = !instance.users.some(function (user) {
- return friend.displayName === user.displayName;
+ return friend.userId === user.id;
});
if (addUser) {
var ref = API.cachedUsers.get(friend.userId);
@@ -10984,7 +10952,7 @@ speechSynthesis.getVoices();
for (var friend of friendsInInstance.values()) {
// if friend isn't in instance add them
var addUser = !instance.users.some(function (user) {
- return friend.displayName === user.displayName;
+ return friend.userId === user.id;
});
if (addUser) {
var ref = API.cachedUsers.get(friend.userId);
@@ -17497,7 +17465,7 @@ speechSynthesis.getVoices();
API.cachedUsers.forEach((ref, id) => {
if (
!this.friends.has(id) &&
- !this.lastLocation.playerList.has(ref.displayName) &&
+ !this.lastLocation.playerList.has(ref.id) &&
id !== API.currentUser.id
) {
API.cachedUsers.delete(id);
@@ -18359,7 +18327,7 @@ speechSynthesis.getVoices();
!this.lastLocation.location ||
this.lastLocation.location !== ref.travelingToLocation ||
ref.id === API.currentUser.id ||
- this.lastLocation.playerList.has(ref.displayName)
+ this.lastLocation.playerList.has(ref.id)
) {
return;
}
@@ -18518,7 +18486,7 @@ speechSynthesis.getVoices();
);
$app.methods.updateDatabaseVersion = async function () {
- var databaseVersion = 9;
+ var databaseVersion = 10;
if (this.databaseVersion < databaseVersion) {
if (this.databaseVersion) {
var msgBox = this.$message({
@@ -18541,6 +18509,7 @@ speechSynthesis.getVoices();
await database.fixBrokenNotifications(); // fix notifications being null
await database.fixBrokenGroupChange(); // fix spam group left & name change
await database.fixCancelFriendRequestTypo(); // fix CancelFriendRequst typo
+ await database.fixBrokenGameLogDisplayNames(); // fix gameLog display names "DisplayName (userId)"
await database.vacuum(); // succ
await configRepository.setInt(
'VRCX_databaseVersion',
diff --git a/html/src/classes/gameLog.js b/html/src/classes/gameLog.js
index 43869fe4..9923c20f 100644
--- a/html/src/classes/gameLog.js
+++ b/html/src/classes/gameLog.js
@@ -30,7 +30,6 @@ export default class extends baseClass {
}
},
gameLogSessionTable: [],
- gameLogApiLoggingEnabled: false,
lastVideoUrl: '',
lastResourceloadUrl: ''
};
@@ -121,62 +120,30 @@ export default class extends baseClass {
joinTime,
lastAvatar: ''
};
- this.lastLocation.playerList.set(
- gameLog.displayName,
- userMap
- );
- if (userId) {
- var ref = API.cachedUsers.get(userId);
- if (userId === API.currentUser.id) {
- // skip
- } else if (this.friends.has(userId)) {
- this.lastLocation.friendList.set(
- gameLog.displayName,
- userMap
- );
- if (
- ref.location !== this.lastLocation.location &&
- ref.travelingToLocation !==
- this.lastLocation.location
- ) {
- // fix $location_at with private
- ref.$location_at = joinTime;
- }
- } else if (typeof ref !== 'undefined') {
- // set $location_at to join time if user isn't a friend
+ this.lastLocation.playerList.set(userId, userMap);
+ var ref = API.cachedUsers.get(userId);
+ if (!userId) {
+ console.error('Missing userId:', gameLog.displayName);
+ } else if (userId === API.currentUser.id) {
+ // skip
+ } else if (this.friends.has(userId)) {
+ this.lastLocation.friendList.set(userId, userMap);
+ if (
+ ref.location !== this.lastLocation.location &&
+ ref.travelingToLocation !==
+ this.lastLocation.location
+ ) {
+ // fix $location_at with private
ref.$location_at = joinTime;
- } else {
- if (this.debugGameLog || this.debugWebRequests) {
- console.log(
- 'Fetching user from gameLog:',
- userId
- );
- }
- API.getUser({ userId });
}
+ } else if (typeof ref !== 'undefined') {
+ // set $location_at to join time if user isn't a friend
+ ref.$location_at = joinTime;
} else {
- // TODO: remove this
- // try fetch userId from previous encounter using database
- database
- .getUserIdFromDisplayName(gameLog.displayName)
- .then((oldUserId) => {
- if (this.isGameRunning) {
- if (oldUserId) {
- API.getUser({ userId: oldUserId });
- } else if (
- Date.now() - joinTime <
- 5 * 1000
- ) {
- workerTimers.setTimeout(
- () =>
- this.silentSearchUser(
- gameLog.displayName
- ),
- 10 * 1000
- );
- }
- }
- });
+ if (this.debugGameLog || this.debugWebRequests) {
+ console.log('Fetching user from gameLog:', userId);
+ }
+ API.getUser({ userId });
}
this.updateVRLastLocation();
this.getCurrentInstanceUserList();
@@ -191,15 +158,13 @@ export default class extends baseClass {
database.addGamelogJoinLeaveToDatabase(entry);
break;
case 'player-left':
- var ref = this.lastLocation.playerList.get(
- gameLog.displayName
- );
+ var ref = this.lastLocation.playerList.get(userId);
if (typeof ref === 'undefined') {
break;
}
var time = Date.now() - ref.joinTime;
- this.lastLocation.playerList.delete(gameLog.displayName);
- this.lastLocation.friendList.delete(gameLog.displayName);
+ this.lastLocation.playerList.delete(userId);
+ this.lastLocation.friendList.delete(userId);
this.photonLobbyAvatars.delete(userId);
this.updateVRLastLocation();
this.getCurrentInstanceUserList();
@@ -276,47 +241,25 @@ export default class extends baseClass {
this.processScreenshot(gameLog.screenshotPath);
break;
case 'api-request':
- var bias = Date.parse(gameLog.dt) + 60 * 1000;
- if (
- !this.isGameRunning ||
- this.lastLocation.location === '' ||
- this.lastLocation.location === 'traveling' ||
- bias < Date.now()
- ) {
- break;
- }
- var userId = '';
- try {
- var url = new URL(gameLog.url);
- var urlParams = new URLSearchParams(gameLog.url);
- if (url.pathname.substring(0, 13) === '/api/1/users/') {
- var pathArray = url.pathname.split('/');
- userId = pathArray[4];
- } else if (urlParams.has('userId')) {
- userId = urlParams.get('userId');
- }
- } catch (err) {
- console.error(err);
- }
- if (!userId) {
- break;
- }
- this.gameLogApiLoggingEnabled = true;
- if (
- API.cachedUsers.has(userId) ||
- API.cachedPlayerModerationsUserIds.has(userId)
- ) {
- break;
- }
- if (this.debugGameLog || this.debugWebRequests) {
- console.log('Fetching user from gameLog:', userId);
- }
- API.getUser({ userId });
+ // var userId = '';
+ // try {
+ // var url = new URL(gameLog.url);
+ // var urlParams = new URLSearchParams(gameLog.url);
+ // if (url.pathname.substring(0, 13) === '/api/1/users/') {
+ // var pathArray = url.pathname.split('/');
+ // userId = pathArray[4];
+ // } else if (urlParams.has('userId')) {
+ // userId = urlParams.get('userId');
+ // }
+ // } catch (err) {
+ // console.error(err);
+ // }
+ // if (!userId) {
+ // break;
+ // }
break;
case 'avatar-change':
- var ref = this.lastLocation.playerList.get(
- gameLog.displayName
- );
+ var ref = this.lastLocation.playerList.get(userId);
if (
this.photonLoggingEnabled ||
typeof ref === 'undefined' ||
@@ -326,14 +269,11 @@ export default class extends baseClass {
}
if (!ref.lastAvatar) {
ref.lastAvatar = gameLog.avatarName;
- this.lastLocation.playerList.set(
- gameLog.displayName,
- ref
- );
+ this.lastLocation.playerList.set(userId, ref);
break;
}
ref.lastAvatar = gameLog.avatarName;
- this.lastLocation.playerList.set(gameLog.displayName, ref);
+ this.lastLocation.playerList.set(userId, ref);
var entry = {
created_at: gameLog.dt,
type: 'AvatarChange',
diff --git a/html/src/classes/gameRealtimeLogging.js b/html/src/classes/gameRealtimeLogging.js
index 1c009686..48bcc85c 100644
--- a/html/src/classes/gameRealtimeLogging.js
+++ b/html/src/classes/gameRealtimeLogging.js
@@ -1151,10 +1151,10 @@ export default class extends baseClass {
}
} else if (
!ref.isFriend &&
- this.lastLocation.playerList.has(ref.displayName)
+ this.lastLocation.playerList.has(user.id)
) {
var { joinTime } = this.lastLocation.playerList.get(
- ref.displayName
+ user.id
);
if (!joinTime) {
joinTime = Date.parse(gameLogDate);
diff --git a/html/src/classes/sharedFeed.js b/html/src/classes/sharedFeed.js
index 08c80670..d572f596 100644
--- a/html/src/classes/sharedFeed.js
+++ b/html/src/classes/sharedFeed.js
@@ -97,7 +97,7 @@ export default class extends baseClass {
(this.sharedFeedFilters.wrist.OnPlayerJoining ===
'VIP' &&
isFavorite)) &&
- !$app.lastLocation.playerList.has(ref.displayName)
+ !$app.lastLocation.playerList.has(ref.id)
) {
if (ref.$location.tag === $app.lastLocation.location) {
var feedEntry = {
diff --git a/html/src/repository/database.js b/html/src/repository/database.js
index 0b6b78bd..e7e50581 100644
--- a/html/src/repository/database.js
+++ b/html/src/repository/database.js
@@ -2616,6 +2616,31 @@ class Database {
);
}
+ 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
+ }
+ );
+ });
+ }
+
async vacuum() {
await sqliteService.executeNonQuery('VACUUM');
}