mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
cachedFavoritesByObjectId
This commit is contained in:
@@ -190,7 +190,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
|||||||
D.galleryImages = [];
|
D.galleryImages = [];
|
||||||
D.galleryLoading = true;
|
D.galleryLoading = true;
|
||||||
D.isFavorite =
|
D.isFavorite =
|
||||||
favoriteStore.cachedFavoritesByObjectId.has(avatarId) ||
|
favoriteStore.cachedFavoritesByObjectId(avatarId) ||
|
||||||
(userStore.isLocalUserVrcPlusSupporter &&
|
(userStore.isLocalUserVrcPlusSupporter &&
|
||||||
favoriteStore.localAvatarFavoritesList.includes(avatarId));
|
favoriteStore.localAvatarFavoritesList.includes(avatarId));
|
||||||
D.isBlocked = cachedAvatarModerations.has(avatarId);
|
D.isBlocked = cachedAvatarModerations.has(avatarId);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
favoriteAvatars_: []
|
favoriteAvatars_: []
|
||||||
});
|
});
|
||||||
|
|
||||||
const cachedFavorites = ref(new Map());
|
const cachedFavorites = reactive(new Map());
|
||||||
|
|
||||||
const currentFavoriteTab = ref('friend');
|
const currentFavoriteTab = ref('friend');
|
||||||
|
|
||||||
@@ -130,7 +130,14 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
currentGroup: {}
|
currentGroup: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
const cachedFavoritesByObjectId = ref(new Map());
|
const cachedFavoritesByObjectId = computed(() => (objectId) => {
|
||||||
|
for (const item of cachedFavorites.values()) {
|
||||||
|
if (item.favoriteId === objectId) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
const localAvatarFavoriteGroups = computed(() =>
|
const localAvatarFavoriteGroups = computed(() =>
|
||||||
Object.keys(localAvatarFavorites.value).sort()
|
Object.keys(localAvatarFavorites.value).sort()
|
||||||
@@ -185,8 +192,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
() => watchState.isLoggedIn,
|
() => watchState.isLoggedIn,
|
||||||
(isLoggedIn) => {
|
(isLoggedIn) => {
|
||||||
friendStore.localFavoriteFriends.clear();
|
friendStore.localFavoriteFriends.clear();
|
||||||
cachedFavorites.value.clear();
|
cachedFavorites.clear();
|
||||||
cachedFavoritesByObjectId.value.clear();
|
|
||||||
cachedFavoriteGroups.value = {};
|
cachedFavoriteGroups.value = {};
|
||||||
favoriteFriendGroups.value = [];
|
favoriteFriendGroups.value = [];
|
||||||
favoriteWorldGroups.value = [];
|
favoriteWorldGroups.value = [];
|
||||||
@@ -279,11 +285,10 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleFavoriteDelete(args) {
|
function handleFavoriteDelete(args) {
|
||||||
const ref = cachedFavoritesByObjectId.value.get(args.params.objectId);
|
const ref = cachedFavoritesByObjectId.value(args.params.objectId);
|
||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cachedFavoritesByObjectId.value.delete(args.params.objectId);
|
|
||||||
friendStore.localFavoriteFriends.delete(args.params.objectId);
|
friendStore.localFavoriteFriends.delete(args.params.objectId);
|
||||||
friendStore.updateSidebarFriendsList();
|
friendStore.updateSidebarFriendsList();
|
||||||
if (ref.$isDeleted) {
|
if (ref.$isDeleted) {
|
||||||
@@ -309,11 +314,10 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
|
|
||||||
function handleFavoriteGroupClear(args) {
|
function handleFavoriteGroupClear(args) {
|
||||||
const key = `${args.params.type}:${args.params.group}`;
|
const key = `${args.params.type}:${args.params.group}`;
|
||||||
for (const ref of cachedFavorites.value.values()) {
|
for (const ref of cachedFavorites.values()) {
|
||||||
if (ref.$isDeleted || ref.$groupKey !== key) {
|
if (ref.$isDeleted || ref.$groupKey !== key) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cachedFavoritesByObjectId.value.delete(ref.favoriteId);
|
|
||||||
friendStore.localFavoriteFriends.delete(ref.favoriteId);
|
friendStore.localFavoriteFriends.delete(ref.favoriteId);
|
||||||
friendStore.updateSidebarFriendsList();
|
friendStore.updateSidebarFriendsList();
|
||||||
ref.$isDeleted = true;
|
ref.$isDeleted = true;
|
||||||
@@ -346,8 +350,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
|
|
||||||
function expireFavorites() {
|
function expireFavorites() {
|
||||||
friendStore.localFavoriteFriends.clear();
|
friendStore.localFavoriteFriends.clear();
|
||||||
cachedFavorites.value.clear();
|
cachedFavorites.clear();
|
||||||
cachedFavoritesByObjectId.value.clear();
|
|
||||||
state.favoriteObjects.clear();
|
state.favoriteObjects.clear();
|
||||||
state.favoriteFriends_ = [];
|
state.favoriteFriends_ = [];
|
||||||
state.favoriteWorlds_ = [];
|
state.favoriteWorlds_ = [];
|
||||||
@@ -399,7 +402,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
*/
|
*/
|
||||||
async function applyFavorite(type, objectId, sortTop = false) {
|
async function applyFavorite(type, objectId, sortTop = false) {
|
||||||
let ref;
|
let ref;
|
||||||
const favorite = cachedFavoritesByObjectId.value.get(objectId);
|
const favorite = cachedFavoritesByObjectId.value(objectId);
|
||||||
let ctx = state.favoriteObjects.get(objectId);
|
let ctx = state.favoriteObjects.get(objectId);
|
||||||
if (typeof favorite !== 'undefined') {
|
if (typeof favorite !== 'undefined') {
|
||||||
let isTypeChanged = false;
|
let isTypeChanged = false;
|
||||||
@@ -690,7 +693,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
}
|
}
|
||||||
// update favorites
|
// update favorites
|
||||||
|
|
||||||
for (ref of cachedFavorites.value.values()) {
|
for (ref of cachedFavorites.values()) {
|
||||||
if (ref.$isDeleted) {
|
if (ref.$isDeleted) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -789,7 +792,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
function applyFavoriteCached(json) {
|
function applyFavoriteCached(json) {
|
||||||
let ref = cachedFavorites.value.get(json.id);
|
let ref = cachedFavorites.get(json.id);
|
||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
ref = {
|
ref = {
|
||||||
id: '',
|
id: '',
|
||||||
@@ -803,8 +806,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
//
|
//
|
||||||
...json
|
...json
|
||||||
};
|
};
|
||||||
cachedFavorites.value.set(ref.id, ref);
|
cachedFavorites.set(ref.id, ref);
|
||||||
cachedFavoritesByObjectId.value.set(ref.favoriteId, ref);
|
|
||||||
if (
|
if (
|
||||||
ref.type === 'friend' &&
|
ref.type === 'friend' &&
|
||||||
(generalSettingsStore.localFavoriteFriendsGroups.length === 0 ||
|
(generalSettingsStore.localFavoriteFriendsGroups.length === 0 ||
|
||||||
@@ -834,7 +836,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function deleteExpiredFavorites() {
|
function deleteExpiredFavorites() {
|
||||||
for (const ref of cachedFavorites.value.values()) {
|
for (const ref of cachedFavorites.values()) {
|
||||||
if (ref.$isDeleted || ref.$isExpired === false) {
|
if (ref.$isDeleted || ref.$isExpired === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -872,7 +874,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
avatar: [0, favoriteRequest.getFavoriteAvatars]
|
avatar: [0, favoriteRequest.getFavoriteAvatars]
|
||||||
};
|
};
|
||||||
const tags = [];
|
const tags = [];
|
||||||
for (const ref of cachedFavorites.value.values()) {
|
for (const ref of cachedFavorites.values()) {
|
||||||
if (ref.$isDeleted) {
|
if (ref.$isDeleted) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1304,7 +1306,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
avatarStore.avatarDialog.id === avatarId
|
avatarStore.avatarDialog.id === avatarId
|
||||||
) {
|
) {
|
||||||
avatarStore.avatarDialog.isFavorite =
|
avatarStore.avatarDialog.isFavorite =
|
||||||
cachedFavoritesByObjectId.value.has(avatarId);
|
cachedFavoritesByObjectId.value(avatarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
@@ -1431,7 +1433,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
worldStore.worldDialog.id === worldId
|
worldStore.worldDialog.id === worldId
|
||||||
) {
|
) {
|
||||||
worldStore.worldDialog.isFavorite =
|
worldStore.worldDialog.isFavorite =
|
||||||
cachedFavoritesByObjectId.value.has(worldId);
|
cachedFavoritesByObjectId.value(worldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
|
|||||||
@@ -572,9 +572,7 @@ export const usePhotonStore = defineStore('Photon', () => {
|
|||||||
hudTimeout.forEach((item) => {
|
hudTimeout.forEach((item) => {
|
||||||
if (
|
if (
|
||||||
timeoutHudOverlayFilter.value === 'VIP' &&
|
timeoutHudOverlayFilter.value === 'VIP' &&
|
||||||
favoriteStore.cachedFavoritesByObjectId.has(
|
favoriteStore.cachedFavoritesByObjectId(item.userId)
|
||||||
item.userId
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
filteredHudTimeout.push(item);
|
filteredHudTimeout.push(item);
|
||||||
} else if (
|
} else if (
|
||||||
|
|||||||
@@ -835,8 +835,9 @@ export const useUserStore = defineStore('User', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
D.isFavorite =
|
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
|
||||||
favoriteStore.cachedFavoritesByObjectId.has(D.id);
|
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') {
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
});
|
});
|
||||||
worldStore.cachedWorlds.forEach((ref, id) => {
|
worldStore.cachedWorlds.forEach((ref, id) => {
|
||||||
if (
|
if (
|
||||||
!favoriteStore.cachedFavoritesByObjectId.has(id) &&
|
!favoriteStore.cachedFavoritesByObjectId(id) &&
|
||||||
ref.authorId !== userStore.currentUser.id &&
|
ref.authorId !== userStore.currentUser.id &&
|
||||||
!favoriteStore.localWorldFavoritesList.includes(id)
|
!favoriteStore.localWorldFavoritesList.includes(id)
|
||||||
) {
|
) {
|
||||||
@@ -271,7 +271,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
});
|
});
|
||||||
avatarStore.cachedAvatars.forEach((ref, id) => {
|
avatarStore.cachedAvatars.forEach((ref, id) => {
|
||||||
if (
|
if (
|
||||||
!favoriteStore.cachedFavoritesByObjectId.has(id) &&
|
!favoriteStore.cachedFavoritesByObjectId(id) &&
|
||||||
ref.authorId !== userStore.currentUser.id &&
|
ref.authorId !== userStore.currentUser.id &&
|
||||||
!favoriteStore.localAvatarFavoritesList.includes(id) &&
|
!favoriteStore.localAvatarFavoritesList.includes(id) &&
|
||||||
!avatarStore.avatarHistory.has(id)
|
!avatarStore.avatarHistory.has(id)
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export const useWorldStore = defineStore('World', () => {
|
|||||||
if (D.id === args.ref.id) {
|
if (D.id === args.ref.id) {
|
||||||
D.loading = false;
|
D.loading = false;
|
||||||
D.ref = args.ref;
|
D.ref = args.ref;
|
||||||
D.isFavorite = favoriteStore.cachedFavoritesByObjectId.has(
|
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
|
||||||
D.id
|
D.id
|
||||||
);
|
);
|
||||||
if (!D.isFavorite) {
|
if (!D.isFavorite) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
style="margin-left: 5px"
|
style="margin-left: 5px"
|
||||||
@click.stop="selectAvatarWithConfirmation(favorite.id)"></el-button>
|
@click.stop="selectAvatarWithConfirmation(favorite.id)"></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<template v-if="cachedFavoritesByObjectId.has(favorite.id)">
|
<template v-if="cachedFavoritesByObjectId(favorite.id)">
|
||||||
<el-tooltip placement="right" content="Favorite" :teleported="false">
|
<el-tooltip placement="right" content="Favorite" :teleported="false">
|
||||||
<el-button
|
<el-button
|
||||||
type="default"
|
type="default"
|
||||||
@@ -53,8 +53,7 @@
|
|||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const { cachedFavoritesByObjectId } = storeToRefs(useFavoriteStore());
|
const { showFavoriteDialog, cachedFavoritesByObjectId } = useFavoriteStore();
|
||||||
const { showFavoriteDialog } = useFavoriteStore();
|
|
||||||
const { selectAvatarWithConfirmation } = useAvatarStore();
|
const { selectAvatarWithConfirmation } = useAvatarStore();
|
||||||
const { currentUser } = storeToRefs(useUserStore());
|
const { currentUser } = storeToRefs(useUserStore());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user