mirror of
https://github.com/vrcx-team/VRCX.git
synced 2026-04-06 00:32:02 +02:00
fix local friend favorites
This commit is contained in:
@@ -32,18 +32,22 @@
|
||||
</div>
|
||||
<div v-if="favoriteDialog.type === 'friend'" style="margin-top: 20px">
|
||||
<span style="display: block; text-align: center">{{ t('dialog.favorite.local_favorites') }}</span>
|
||||
<template v-for="group in localFriendFavoriteGroups" :key="group">
|
||||
<template v-if="currentLocalFriendGroup">
|
||||
<Button
|
||||
variant="outline"
|
||||
v-if="hasLocalFriendFavorite(favoriteDialog.objectId, group)"
|
||||
style="width: 100%; white-space: initial"
|
||||
class="my-1"
|
||||
@click="removeLocalFriendFavorite(favoriteDialog.objectId, group)">
|
||||
<Check />{{ group }} ({{ localFriendFavGroupLength(group) }})
|
||||
@click="removeLocalFriendFavorite(favoriteDialog.objectId, currentLocalFriendGroup)">
|
||||
<Check />{{ currentLocalFriendGroup }} ({{
|
||||
localFriendFavGroupLength(currentLocalFriendGroup)
|
||||
}})
|
||||
</Button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<Button
|
||||
variant="outline"
|
||||
v-else
|
||||
v-for="group in localFriendFavoriteGroups"
|
||||
:key="group"
|
||||
style="width: 100%; white-space: initial"
|
||||
class="my-1"
|
||||
@click="addLocalFriendFavorite(favoriteDialog.objectId, group)">
|
||||
@@ -150,6 +154,16 @@
|
||||
}
|
||||
});
|
||||
|
||||
const currentLocalFriendGroup = computed(() => {
|
||||
const objectId = favoriteDialog.value.objectId;
|
||||
for (const group of localFriendFavoriteGroups.value) {
|
||||
if (hasLocalFriendFavorite(objectId, group)) {
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => favoriteDialog.value.visible,
|
||||
(value) => {
|
||||
|
||||
@@ -1536,6 +1536,15 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
if (hasLocalFriendFavorite(userId, group)) {
|
||||
return;
|
||||
}
|
||||
for (const existingGroup in localFriendFavorites) {
|
||||
const members = localFriendFavorites[existingGroup];
|
||||
const idx = members?.indexOf(userId);
|
||||
if (idx !== undefined && idx !== -1) {
|
||||
members.splice(idx, 1);
|
||||
database.removeFriendFromLocalFavorites(userId, existingGroup);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!localFriendFavorites[group]) {
|
||||
localFriendFavorites[group] = [];
|
||||
}
|
||||
@@ -1547,6 +1556,10 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
) {
|
||||
updateFavoriteDialog(userId);
|
||||
}
|
||||
const userDialog = userStore.userDialog;
|
||||
if (userDialog.visible && userDialog.id === userId) {
|
||||
userDialog.isFavorite = true;
|
||||
}
|
||||
if (
|
||||
generalSettingsStore.localFavoriteFriendsGroups.includes(
|
||||
`local:${group}`
|
||||
@@ -1569,6 +1582,20 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
return favoriteGroup.includes(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is in any local friend favorite group.
|
||||
* @param {string} userId
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isInAnyLocalFriendGroup(userId) {
|
||||
for (const group in localFriendFavorites) {
|
||||
if (localFriendFavorites[group]?.includes(userId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} userId
|
||||
* @param {string} group
|
||||
@@ -1588,6 +1615,12 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
) {
|
||||
updateFavoriteDialog(userId);
|
||||
}
|
||||
const userDialog = userStore.userDialog;
|
||||
if (userDialog.visible && userDialog.id === userId) {
|
||||
userDialog.isFavorite =
|
||||
getCachedFavoritesByObjectId(userId) ||
|
||||
isInAnyLocalFriendGroup(userId);
|
||||
}
|
||||
if (
|
||||
generalSettingsStore.localFavoriteFriendsGroups.includes(
|
||||
`local:${group}`
|
||||
@@ -1806,6 +1839,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
getCachedFavoriteGroupsByTypeName,
|
||||
addLocalFriendFavorite,
|
||||
hasLocalFriendFavorite,
|
||||
isInAnyLocalFriendGroup,
|
||||
removeLocalFriendFavorite,
|
||||
deleteLocalFriendFavoriteGroup,
|
||||
renameLocalFriendFavoriteGroup,
|
||||
|
||||
@@ -907,9 +907,9 @@ export const useUserStore = defineStore('User', () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
D.isFavorite = favoriteStore.getCachedFavoritesByObjectId(
|
||||
D.id
|
||||
);
|
||||
D.isFavorite =
|
||||
favoriteStore.getCachedFavoritesByObjectId(D.id) ||
|
||||
favoriteStore.isInAnyLocalFriendGroup(D.id);
|
||||
if (D.ref.friendRequestStatus === 'incoming') {
|
||||
D.incomingRequest = true;
|
||||
} else if (D.ref.friendRequestStatus === 'outgoing') {
|
||||
|
||||
@@ -307,6 +307,7 @@
|
||||
{{ t('view.favorite.clear') }}
|
||||
</Button>
|
||||
<Button
|
||||
v-if="!isLocalGroupSelected"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
:disabled="!hasFriendSelection"
|
||||
@@ -493,7 +494,8 @@
|
||||
localFriendFavGroupLength,
|
||||
deleteLocalFriendFavoriteGroup,
|
||||
renameLocalFriendFavoriteGroup,
|
||||
newLocalFriendFavoriteGroup
|
||||
newLocalFriendFavoriteGroup,
|
||||
removeLocalFriendFavorite
|
||||
} = favoriteStore;
|
||||
const userStore = useUserStore();
|
||||
const { showUserDialog } = userStore;
|
||||
@@ -935,11 +937,17 @@
|
||||
}
|
||||
|
||||
function bulkUnfavoriteSelectedFriends(ids) {
|
||||
ids.forEach((id) => {
|
||||
favoriteRequest.deleteFavorite({
|
||||
objectId: id
|
||||
if (isLocalGroupSelected.value && activeLocalGroupName.value) {
|
||||
ids.forEach((id) => {
|
||||
removeLocalFriendFavorite(id, activeLocalGroupName.value);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ids.forEach((id) => {
|
||||
favoriteRequest.deleteFavorite({
|
||||
objectId: id
|
||||
});
|
||||
});
|
||||
}
|
||||
selectedFavoriteFriends.value = [];
|
||||
friendEditMode.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user