Custom favorite friend groups

This commit is contained in:
Natsumi
2024-04-11 14:02:54 +12:00
parent 708cc1ff37
commit a5d29c0e9b
4 changed files with 117 additions and 39 deletions

View File

@@ -3977,6 +3977,7 @@ speechSynthesis.getVoices();
};
API.$on('LOGIN', function () {
$app.localFavoriteFriends.clear();
this.cachedFavorites.clear();
this.cachedFavoritesByObjectId.clear();
this.cachedFavoriteGroups.clear();
@@ -4044,6 +4045,8 @@ speechSynthesis.getVoices();
}
// 애초에 $isDeleted인데 여기로 올 수 가 있나..?
this.cachedFavoritesByObjectId.delete(args.params.objectId);
$app.localFavoriteFriends.delete(args.params.objectId);
$app.updateSidebarFriendsList();
if (ref.$isDeleted) {
return;
}
@@ -4096,6 +4099,8 @@ speechSynthesis.getVoices();
continue;
}
this.cachedFavoritesByObjectId.delete(ref.favoriteId);
$app.localFavoriteFriends.delete(ref.favoriteId);
$app.updateSidebarFriendsList();
ref.$isDeleted = true;
API.$emit('FAVORITE:@DELETE', {
ref,
@@ -4156,6 +4161,14 @@ speechSynthesis.getVoices();
};
this.cachedFavorites.set(ref.id, ref);
this.cachedFavoritesByObjectId.set(ref.favoriteId, ref);
if (
ref.type === 'friend' &&
($app.localFavoriteFriendsGroups.length === 0 ||
$app.localFavoriteFriendsGroups.includes(ref.groupKey))
) {
$app.localFavoriteFriends.add(ref.favoriteId);
$app.updateSidebarFriendsList();
}
} else {
Object.assign(ref, json);
ref.$isExpired = false;
@@ -4172,6 +4185,7 @@ speechSynthesis.getVoices();
};
API.expireFavorites = function () {
$app.localFavoriteFriends.clear();
this.cachedFavorites.clear();
this.cachedFavoritesByObjectId.clear();
$app.favoriteObjects.clear();
@@ -5687,7 +5701,7 @@ speechSynthesis.getVoices();
);
// OnPlayerJoining/Traveling
API.currentTravelers.forEach((ref) => {
var isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
var isFavorite = this.localFavoriteFriends.has(ref.id);
if (
(this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends' ||
(this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP' &&
@@ -5864,12 +5878,12 @@ speechSynthesis.getVoices();
var isFavorite = false;
if (ctx.userId) {
isFriend = this.friends.has(ctx.userId);
isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
isFavorite = this.localFavoriteFriends.has(ctx.userId);
} else if (ctx.displayName) {
for (var ref of API.cachedUsers.values()) {
if (ref.displayName === ctx.displayName) {
isFriend = this.friends.has(ref.id);
isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
isFavorite = this.localFavoriteFriends.has(ref.id);
break;
}
}
@@ -5903,19 +5917,19 @@ speechSynthesis.getVoices();
var entry = {
created_at: ctx.created_at,
type,
displayName: ref.targetDisplayName,
userId: ref.targetUserId,
isFriend,
isFavorite
};
if (
wristFilter[type] &&
(wristFilter[type] === 'Everyone' ||
(wristFilter[type] === 'Friends' && isFriend) ||
(wristFilter[type] === 'VIP' && isFavorite))
) {
wristArr.unshift(entry);
}
displayName: ref.targetDisplayName,
userId: ref.targetUserId,
isFriend,
isFavorite
};
if (
wristFilter[type] &&
(wristFilter[type] === 'Everyone' ||
(wristFilter[type] === 'Friends' && isFriend) ||
(wristFilter[type] === 'VIP' && isFavorite))
) {
wristArr.unshift(entry);
}
this.queueFeedNoty(entry);
}
}
@@ -5987,12 +6001,12 @@ speechSynthesis.getVoices();
noty.isFavorite = false;
if (noty.userId) {
noty.isFriend = this.friends.has(noty.userId);
noty.isFavorite = API.cachedFavoritesByObjectId.has(noty.userId);
noty.isFavorite = this.localFavoriteFriends.has(noty.userId);
} else if (noty.displayName) {
for (var ref of API.cachedUsers.values()) {
if (ref.displayName === noty.displayName) {
noty.isFriend = this.friends.has(ref.id);
noty.isFavorite = API.cachedFavoritesByObjectId.has(ref.id);
noty.isFavorite = this.localFavoriteFriends.has(ref.id);
break;
}
}
@@ -6046,7 +6060,7 @@ speechSynthesis.getVoices();
continue;
}
var isFriend = this.friends.has(ctx.userId);
var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
var isFavorite = this.localFavoriteFriends.has(ctx.userId);
if (
w < 20 &&
wristFilter[ctx.type] &&
@@ -6078,7 +6092,7 @@ speechSynthesis.getVoices();
return;
}
noty.isFriend = this.friends.has(noty.userId);
noty.isFavorite = API.cachedFavoritesByObjectId.has(noty.userId);
noty.isFavorite = this.localFavoriteFriends.has(noty.userId);
var notyFilter = this.sharedFeedFilters.noty;
if (
notyFilter[noty.type] &&
@@ -6120,9 +6134,7 @@ speechSynthesis.getVoices();
continue;
}
var isFriend = this.friends.has(ctx.senderUserId);
var isFavorite = API.cachedFavoritesByObjectId.has(
ctx.senderUserId
);
var isFavorite = this.localFavoriteFriends.has(ctx.senderUserId);
if (
w < 20 &&
wristFilter[ctx.type] &&
@@ -6144,7 +6156,7 @@ speechSynthesis.getVoices();
$app.methods.queueNotificationNoty = function (noty) {
noty.isFriend = this.friends.has(noty.senderUserId);
noty.isFavorite = API.cachedFavoritesByObjectId.has(noty.senderUserId);
noty.isFavorite = this.localFavoriteFriends.has(noty.senderUserId);
var notyFilter = this.sharedFeedFilters.noty;
if (
notyFilter[noty.type] &&
@@ -6186,7 +6198,7 @@ speechSynthesis.getVoices();
continue;
}
var isFriend = this.friends.has(ctx.userId);
var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
var isFavorite = this.localFavoriteFriends.has(ctx.userId);
if (
w < 20 &&
wristFilter[ctx.type] &&
@@ -6211,7 +6223,7 @@ speechSynthesis.getVoices();
return;
}
noty.isFriend = this.friends.has(noty.userId);
noty.isFavorite = API.cachedFavoritesByObjectId.has(noty.userId);
noty.isFavorite = this.localFavoriteFriends.has(noty.userId);
var notyFilter = this.sharedFeedFilters.noty;
if (
notyFilter[noty.type] &&
@@ -6252,7 +6264,7 @@ speechSynthesis.getVoices();
break;
}
var isFriend = this.friends.has(ctx.userId);
var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId);
var isFavorite = this.localFavoriteFriends.has(ctx.userId);
// add tag colour
var tagColour = '';
var tagRef = this.customUserTags.get(ctx.userId);
@@ -6282,7 +6294,7 @@ speechSynthesis.getVoices();
noty.isFavorite = false;
if (noty.userId) {
noty.isFriend = this.friends.has(noty.userId);
noty.isFavorite = API.cachedFavoritesByObjectId.has(noty.userId);
noty.isFavorite = this.localFavoriteFriends.has(noty.userId);
}
var notyFilter = this.sharedFeedFilters.noty;
if (notyFilter[noty.type] && notyFilter[noty.type] === 'On') {
@@ -8758,7 +8770,7 @@ speechSynthesis.getVoices();
return;
}
var ref = API.cachedUsers.get(id);
var isVIP = API.cachedFavoritesByObjectId.has(id);
var isVIP = this.localFavoriteFriends.has(id);
var ctx = {
id,
state: state || 'offline',
@@ -8889,7 +8901,7 @@ speechSynthesis.getVoices();
ctx.pendingOffline = false;
}
var ref = API.cachedUsers.get(id);
var isVIP = API.cachedFavoritesByObjectId.has(id);
var isVIP = this.localFavoriteFriends.has(id);
var location = '';
var $location_at = '';
if (typeof ref !== 'undefined') {
@@ -10116,10 +10128,7 @@ speechSynthesis.getVoices();
) {
return;
}
if (
this.feedTable.vip &&
!API.cachedFavoritesByObjectId.has(feed.userId)
) {
if (this.feedTable.vip && !this.localFavoriteFriends.has(feed.userId)) {
return;
}
if (!this.feedSearch(feed)) {
@@ -11344,7 +11353,7 @@ speechSynthesis.getVoices();
userId = photonUserRef.id;
isFriend = photonUserRef.isFriend;
}
var isFavorite = API.cachedFavoritesByObjectId.has(userId);
var isFavorite = this.localFavoriteFriends.has(userId);
var colour = '';
var tagRef = this.customUserTags.get(userId);
if (typeof tagRef !== 'undefined') {
@@ -27399,6 +27408,63 @@ speechSynthesis.getVoices();
this.worldFavoriteSearchResults = results;
};
// #endregion
// #region | Local Favorite Friends
$app.data.localFavoriteFriends = new Set();
$app.data.localFavoriteFriendsGroups = JSON.parse(
await configRepository.getString(
'VRCX_localFavoriteFriendsGroups',
'[]'
)
);
$app.methods.updateLocalFavoriteFriends = function () {
this.localFavoriteFriends.clear();
for (var ref of API.cachedFavorites.values()) {
if (
ref.$isDeleted === false &&
ref.type === 'friend' &&
(this.localFavoriteFriendsGroups.length === 0 ||
this.localFavoriteFriendsGroups.includes(ref.$groupKey))
) {
this.localFavoriteFriends.add(ref.favoriteId);
}
}
this.updateSidebarFriendsList();
configRepository.setString(
'VRCX_localFavoriteFriendsGroups',
JSON.stringify(this.localFavoriteFriendsGroups)
);
};
$app.methods.updateSidebarFriendsList = function () {
for (var ctx of this.friends.values()) {
var isVIP = this.localFavoriteFriends.has(ctx.id);
if (ctx.isVIP === isVIP) {
continue;
}
ctx.isVIP = isVIP;
if (ctx.state !== 'online') {
continue;
}
if (ctx.isVIP) {
removeFromArray(this.friendsGroup1_, ctx);
removeFromArray(this.friendsGroupB_, ctx);
this.sortFriendsGroup0 = true;
this.friendsGroup0_.push(ctx);
this.friendsGroupA_.unshift(ctx);
} else {
removeFromArray(this.friendsGroup0_, ctx);
removeFromArray(this.friendsGroupA_, ctx);
this.sortFriendsGroup1 = true;
this.friendsGroup1_.push(ctx);
this.friendsGroupB_.unshift(ctx);
}
}
};
// #endregion
// #region | App: pending offline timer
@@ -29641,10 +29707,10 @@ speechSynthesis.getVoices();
if (typeof row.isFavorite !== 'undefined') {
return row.isFavorite;
}
if (!row.userId || API.cachedFavoritesByObjectId.size === 0) {
if (!row.userId) {
return false;
}
row.isFavorite = API.cachedFavoritesByObjectId.has(row.userId);
row.isFavorite = this.localFavoriteFriends.has(row.userId);
return row.isFavorite;
};

View File

@@ -213,9 +213,13 @@
"minimized": "Start as minimized state",
"tray": "Close to tray"
},
"favorites": {
"header": "Favorite Friends",
"group_placeholder": "Choose Groups"
},
"game_log": {
"header": "Game Log",
"resource_load": "Log Udon resource load"
"resource_load": "Log Udon string/image load"
},
"automation": {
"header": "Automation",

View File

@@ -1620,4 +1620,4 @@
"online": "En línea:"
}
}
}
}

View File

@@ -84,6 +84,14 @@ mixin settingsTab()
+simpleSwitch("view.settings.general.application.startup", "isStartAtWindowsStartup", "saveVRCXWindowOption")
+simpleSwitch("view.settings.general.application.minimized", "isStartAsMinimizedState", "saveVRCXWindowOption")
+simpleSwitch("view.settings.general.application.tray", "isCloseToTray", "saveVRCXWindowOption")
//- General | Favorite
+simpleSettingsCategory("view.settings.general.favorites.header")
br
el-select(v-model="localFavoriteFriendsGroups" multiple clearable :placeholder="$t('view.settings.general.favorites.group_placeholder')" @change="updateLocalFavoriteFriends")
el-option-group(:label="$t('view.settings.general.favorites.group_placeholder')")
el-option.x-friend-item(v-for="group in API.favoriteFriendGroups" :key="group.key" :label="group.displayName ? group.displayName : group.name" :value="group.key")
.detail
span.name(v-text="group.displayName ? group.displayName : group.name")
//- General | Game Log
+simpleSettingsCategory("view.settings.general.game_log.header")
+simpleSwitch("view.settings.general.game_log.resource_load", "logResourceLoad", "saveGameLogOptions")