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
@@ -539,8 +539,8 @@
User, User,
Warning Warning
} from '@element-plus/icons-vue'; } 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 { 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 { computed, defineAsyncComponent, nextTick, ref, watch } from 'vue';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { ElMessageBox } from 'element-plus'; import { ElMessageBox } from 'element-plus';
+6 -4
View File
@@ -134,6 +134,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
} }
favoriteStore.applyFavorite('avatar', ref.id); favoriteStore.applyFavorite('avatar', ref.id);
if (favoriteStore.localAvatarFavoritesList.includes(ref.id)) { if (favoriteStore.localAvatarFavoritesList.includes(ref.id)) {
const avatarRef = ref;
for ( for (
let i = 0; let i = 0;
i < favoriteStore.localAvatarFavoriteGroups.length; i < favoriteStore.localAvatarFavoriteGroups.length;
@@ -148,16 +149,17 @@ export const useAvatarStore = defineStore('Avatar', () => {
j < favoriteStore.localAvatarFavorites[groupName].length; j < favoriteStore.localAvatarFavorites[groupName].length;
++j ++j
) { ) {
const ref = const favoriteRef =
favoriteStore.localAvatarFavorites[groupName][j]; favoriteStore.localAvatarFavorites[groupName][j];
if (ref.id === ref.id) { if (favoriteRef.id === avatarRef.id) {
favoriteStore.localAvatarFavorites[groupName][j] = ref; favoriteStore.localAvatarFavorites[groupName][j] =
avatarRef;
} }
} }
} }
// update db cache // update db cache
database.addAvatarToCache(ref); database.addAvatarToCache(avatarRef);
} }
return ref; return ref;
} }
+9 -6
View File
@@ -37,6 +37,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
}); });
const cachedFavorites = reactive(new Map()); const cachedFavorites = reactive(new Map());
const cachedFavoritesByObjectId = reactive(new Map());
const cachedFavoriteGroups = ref({}); const cachedFavoriteGroups = ref({});
@@ -205,6 +206,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
(isLoggedIn) => { (isLoggedIn) => {
friendStore.localFavoriteFriends.clear(); friendStore.localFavoriteFriends.clear();
cachedFavorites.clear(); cachedFavorites.clear();
cachedFavoritesByObjectId.clear();
cachedFavoriteGroups.value = {}; cachedFavoriteGroups.value = {};
favoriteFriendGroups.value = []; favoriteFriendGroups.value = [];
favoriteWorldGroups.value = []; favoriteWorldGroups.value = [];
@@ -251,12 +253,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
} }
function getCachedFavoritesByObjectId(objectId) { function getCachedFavoritesByObjectId(objectId) {
for (const item of cachedFavorites.values()) { return cachedFavoritesByObjectId.get(objectId);
if (item.favoriteId === objectId) {
return item;
}
}
return undefined;
} }
function handleFavoriteAdd(args) { function handleFavoriteAdd(args) {
@@ -353,6 +350,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
removeFromArray(state.favoriteWorlds_, favorite); removeFromArray(state.favoriteWorlds_, favorite);
removeFromArray(state.favoriteAvatars_, favorite); removeFromArray(state.favoriteAvatars_, favorite);
cachedFavorites.delete(ref.id); cachedFavorites.delete(ref.id);
cachedFavoritesByObjectId.delete(ref.favoriteId);
state.favoriteObjects.delete(ref.favoriteId); state.favoriteObjects.delete(ref.favoriteId);
friendStore.localFavoriteFriends.delete(ref.favoriteId); friendStore.localFavoriteFriends.delete(ref.favoriteId);
favoritesSortOrder.value = favoritesSortOrder.value.filter( favoritesSortOrder.value = favoritesSortOrder.value.filter(
@@ -752,6 +750,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
...json ...json
}; };
cachedFavorites.set(ref.id, ref); cachedFavorites.set(ref.id, ref);
cachedFavoritesByObjectId.set(ref.favoriteId, ref);
if ( if (
ref.type === 'friend' && ref.type === 'friend' &&
(generalSettingsStore.localFavoriteFriendsGroups.length === 0 || (generalSettingsStore.localFavoriteFriendsGroups.length === 0 ||
@@ -768,7 +767,11 @@ export const useFavoriteStore = defineStore('Favorite', () => {
++group.count; ++group.count;
} }
} else { } else {
if (ref.favoriteId !== json.favoriteId) {
cachedFavoritesByObjectId.delete(ref.favoriteId);
}
Object.assign(ref, json); Object.assign(ref, json);
cachedFavoritesByObjectId.set(ref.favoriteId, ref);
} }
return ref; return ref;