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