From 71d8cc22bfeff6a5abbe69acecd5fac17ad64262 Mon Sep 17 00:00:00 2001 From: pa Date: Mon, 24 Mar 2025 11:13:35 +0900 Subject: [PATCH] feat: Limit bio display height(#1158), Toggle for display of age gated instances(#1188), fix: (#1189)(#1192) (#1195) --- src/app.js | 51 +++---- src/classes/gameLog.js | 6 +- src/classes/utils.js | 19 +++ src/components/sidebar/GroupsSidebar.vue | 34 +++-- src/localization/en/en.json | 1 + src/mixins/dialogs/userDialog.pug | 2 +- src/mixins/dialogs/worldDialog.pug | 1 + src/mixins/tabs/gameLog.pug | 13 +- src/mixins/tabs/settings.pug | 4 + src/theme.material3.scss | 6 + src/views/SideBar.vue | 4 +- src/views/dialogs/world/WorldDialog.vue | 178 ++++++++++++----------- 12 files changed, 183 insertions(+), 136 deletions(-) diff --git a/src/app.js b/src/app.js index c29db2e0..fc90fc51 100644 --- a/src/app.js +++ b/src/app.js @@ -6908,6 +6908,21 @@ console.log(`isLinux: ${LINUX}`); ); } $app.data.pendingOfflineDelay = 180000; + + // It's a mess, but it'll be fine afterward with the state manager + $app.data.isAgeGatedInstancesVisible = await configRepository.getBool( + 'VRCX_isAgeGatedInstancesVisible', + true + ); + + $app.methods.toggleIsAgeGatedInstancesVisible = function () { + this.isAgeGatedInstancesVisible = !this.isAgeGatedInstancesVisible; + configRepository.setBool( + 'VRCX_isAgeGatedInstancesVisible', + this.isAgeGatedInstancesVisible + ); + }; + if (await configRepository.getString('VRCX_avatarRemoteDatabaseProvider')) { // move existing provider to new list var avatarRemoteDatabaseProvider = await configRepository.getString( @@ -16694,25 +16709,6 @@ console.log(`isLinux: ${LINUX}`); resolution = '128', isUserDialogIcon = false ) { - function convertFileUrlToImageUrl(url) { - /** - * possible patterns? - * /file/file_fileId/version - * /file/file_fileId/version/ - * /file/file_fileId/version/file - * /file/file_fileId/version/file/ - */ - const pattern = /file\/file_([a-f0-9-]+)\/(\d+)(\/file)?\/?$/; - const match = url.match(pattern); - - if (match) { - const fileId = match[1]; - const version = match[2]; - return `https://api.vrchat.cloud/api/1/image/file_${fileId}/${version}/${resolution}`; - } - // return /image/file_fileId url? - return url; - } if (!user) { return ''; } @@ -16721,7 +16717,7 @@ console.log(`isLinux: ${LINUX}`); (this.displayVRCPlusIconsAsAvatar && user.userIcon) ) { if (isIcon) { - return convertFileUrlToImageUrl(user.userIcon); + return $utils.convertFileUrlToImageUrl(user.userIcon); } return user.userIcon; } @@ -16752,7 +16748,9 @@ console.log(`isLinux: ${LINUX}`); } if (user.currentAvatarImageUrl) { if (isIcon) { - return convertFileUrlToImageUrl(user.currentAvatarImageUrl); + return $utils.convertFileUrlToImageUrl( + user.currentAvatarImageUrl + ); } return user.currentAvatarImageUrl; } @@ -19908,12 +19906,8 @@ console.log(`isLinux: ${LINUX}`); ); }; - $app.methods.getSmallThumbnailUrl = function (url, resolution = 128) { - return ( - url - ?.replace('/file/', '/image/') - .replace('/1/file', `/1/${resolution}`) || url - ); + $app.methods.getSmallThumbnailUrl = function (url) { + return $utils.convertFileUrlToImageUrl(url); }; // #endregion @@ -19975,7 +19969,8 @@ console.log(`isLinux: ${LINUX}`); groupInstances: this.groupInstances, inGameGroupOrder: this.inGameGroupOrder, groupedByGroupKeyFavoriteFriends: - this.groupedByGroupKeyFavoriteFriends + this.groupedByGroupKeyFavoriteFriends, + isAgeGatedInstancesVisible: this.isAgeGatedInstancesVisible }; }; diff --git a/src/classes/gameLog.js b/src/classes/gameLog.js index 557e02e6..c5871a21 100644 --- a/src/classes/gameLog.js +++ b/src/classes/gameLog.js @@ -4,6 +4,7 @@ import configRepository from '../repository/config.js'; import database from '../repository/database.js'; import { baseClass, $app, API, $t, $utils } from './baseClass.js'; import { userRequest } from './request'; +import dayjs from 'dayjs'; export default class extends baseClass { constructor(_app, _API, _t) { @@ -168,7 +169,8 @@ export default class extends baseClass { if (typeof friendRef?.ref !== 'undefined') { friendRef.ref.$joinCount++; friendRef.ref.$lastSeen = new Date().toJSON(); - friendRef.ref.$timeSpent += Date.now() - ref.joinTime; + friendRef.ref.$timeSpent += + dayjs(gameLog.dt) - ref.joinTime; if ( this.sidebarSortMethods.includes( 'Sort by Last Seen' @@ -178,7 +180,7 @@ export default class extends baseClass { this.sortOnlineFriends = true; } } - var time = Date.now() - ref.joinTime; + var time = dayjs(gameLog.dt) - ref.joinTime; this.lastLocation.playerList.delete(userId); this.lastLocation.friendList.delete(userId); this.photonLobbyAvatars.delete(userId); diff --git a/src/classes/utils.js b/src/classes/utils.js index 814fbeba..0ae4e07c 100644 --- a/src/classes/utils.js +++ b/src/classes/utils.js @@ -402,5 +402,24 @@ export default { } } return false; + }, + convertFileUrlToImageUrl(url, resolution = 128) { + /** + * possible patterns? + * /file/file_fileId/version + * /file/file_fileId/version/ + * /file/file_fileId/version/file + * /file/file_fileId/version/file/ + */ + const pattern = /file\/file_([a-f0-9-]+)\/(\d+)(\/file)?\/?$/; + const match = url.match(pattern); + + if (match) { + const fileId = match[1]; + const version = match[2]; + return `https://api.vrchat.cloud/api/1/image/file_${fileId}/${version}/${resolution}`; + } + // no match return origin url + return url; } }; diff --git a/src/components/sidebar/GroupsSidebar.vue b/src/components/sidebar/GroupsSidebar.vue index b2ed4e36..5ff75b31 100644 --- a/src/components/sidebar/GroupsSidebar.vue +++ b/src/components/sidebar/GroupsSidebar.vue @@ -22,18 +22,20 @@ :key="ref.instance.id" class="x-friend-item" @click="$emit('show-group-dialog', ref.instance.ownerId)"> -
- -
-
- - - ({{ ref.instance.userCount }}/{{ ref.instance.capacity }}) - - -
+ @@ -42,6 +44,7 @@