import performance

This commit is contained in:
pa
2026-01-12 00:03:30 +09:00
committed by Natsumi
parent 8b29ae9267
commit 2a6a14b7e4
3 changed files with 16 additions and 11 deletions

View File

@@ -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';

View File

@@ -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;
}

View File

@@ -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;