mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 14:23:51 +02:00
import performance
This commit is contained in:
@@ -539,8 +539,8 @@
|
||||
User,
|
||||
Warning
|
||||
} from '@element-plus/icons-vue';
|
||||
import { Check, CircleCheck, Ellipsis, RefreshCcw, Star, Trash2 } from 'lucide-vue-next';
|
||||
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from '@/components/ui/carousel';
|
||||
import { CircleCheck, Ellipsis, RefreshCcw, Star, Trash2 } from 'lucide-vue-next';
|
||||
import { computed, defineAsyncComponent, nextTick, ref, watch } from 'vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
|
||||
@@ -134,6 +134,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
||||
}
|
||||
favoriteStore.applyFavorite('avatar', ref.id);
|
||||
if (favoriteStore.localAvatarFavoritesList.includes(ref.id)) {
|
||||
const avatarRef = ref;
|
||||
for (
|
||||
let i = 0;
|
||||
i < favoriteStore.localAvatarFavoriteGroups.length;
|
||||
@@ -148,16 +149,17 @@ export const useAvatarStore = defineStore('Avatar', () => {
|
||||
j < favoriteStore.localAvatarFavorites[groupName].length;
|
||||
++j
|
||||
) {
|
||||
const ref =
|
||||
const favoriteRef =
|
||||
favoriteStore.localAvatarFavorites[groupName][j];
|
||||
if (ref.id === ref.id) {
|
||||
favoriteStore.localAvatarFavorites[groupName][j] = ref;
|
||||
if (favoriteRef.id === avatarRef.id) {
|
||||
favoriteStore.localAvatarFavorites[groupName][j] =
|
||||
avatarRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update db cache
|
||||
database.addAvatarToCache(ref);
|
||||
database.addAvatarToCache(avatarRef);
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
});
|
||||
|
||||
const cachedFavorites = reactive(new Map());
|
||||
const cachedFavoritesByObjectId = reactive(new Map());
|
||||
|
||||
const cachedFavoriteGroups = ref({});
|
||||
|
||||
@@ -205,6 +206,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
(isLoggedIn) => {
|
||||
friendStore.localFavoriteFriends.clear();
|
||||
cachedFavorites.clear();
|
||||
cachedFavoritesByObjectId.clear();
|
||||
cachedFavoriteGroups.value = {};
|
||||
favoriteFriendGroups.value = [];
|
||||
favoriteWorldGroups.value = [];
|
||||
@@ -251,12 +253,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
}
|
||||
|
||||
function getCachedFavoritesByObjectId(objectId) {
|
||||
for (const item of cachedFavorites.values()) {
|
||||
if (item.favoriteId === objectId) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return cachedFavoritesByObjectId.get(objectId);
|
||||
}
|
||||
|
||||
function handleFavoriteAdd(args) {
|
||||
@@ -353,6 +350,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
removeFromArray(state.favoriteWorlds_, favorite);
|
||||
removeFromArray(state.favoriteAvatars_, favorite);
|
||||
cachedFavorites.delete(ref.id);
|
||||
cachedFavoritesByObjectId.delete(ref.favoriteId);
|
||||
state.favoriteObjects.delete(ref.favoriteId);
|
||||
friendStore.localFavoriteFriends.delete(ref.favoriteId);
|
||||
favoritesSortOrder.value = favoritesSortOrder.value.filter(
|
||||
@@ -752,6 +750,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
...json
|
||||
};
|
||||
cachedFavorites.set(ref.id, ref);
|
||||
cachedFavoritesByObjectId.set(ref.favoriteId, ref);
|
||||
if (
|
||||
ref.type === 'friend' &&
|
||||
(generalSettingsStore.localFavoriteFriendsGroups.length === 0 ||
|
||||
@@ -768,7 +767,11 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
||||
++group.count;
|
||||
}
|
||||
} else {
|
||||
if (ref.favoriteId !== json.favoriteId) {
|
||||
cachedFavoritesByObjectId.delete(ref.favoriteId);
|
||||
}
|
||||
Object.assign(ref, json);
|
||||
cachedFavoritesByObjectId.set(ref.favoriteId, ref);
|
||||
}
|
||||
|
||||
return ref;
|
||||
|
||||
Reference in New Issue
Block a user