This commit is contained in:
pa
2025-11-05 20:51:12 +09:00
committed by Natsumi
parent 24f967aa13
commit b849cdbdd3
11 changed files with 84 additions and 79 deletions
+1 -1
View File
@@ -188,7 +188,7 @@ export const useAvatarStore = defineStore('Avatar', () => {
D.galleryImages = [];
D.galleryLoading = true;
D.isFavorite =
favoriteStore.cachedFavoritesByObjectId(avatarId) ||
favoriteStore.getCachedFavoritesByObjectId(avatarId) ||
(userStore.isLocalUserVrcPlusSupporter &&
favoriteStore.localAvatarFavoritesList.includes(avatarId));
D.isBlocked = cachedAvatarModerations.has(avatarId);
+62 -62
View File
@@ -38,52 +38,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
const cachedFavoriteGroups = ref({});
const cachedFavoriteGroupsByTypeName = computed(() => {
const group = {};
for (const k in favoriteFriendGroups.value) {
const element = favoriteFriendGroups.value[k];
group[element.key] = element;
}
for (const k in favoriteWorldGroups.value) {
const element = favoriteWorldGroups.value[k];
group[element.key] = element;
}
for (const k in favoriteAvatarGroups.value) {
const element = favoriteAvatarGroups.value[k];
group[element.key] = element;
}
return group;
});
const favoriteFriends = computed(() => {
if (appearanceSettingsStore.sortFavorites) {
return state.favoriteFriends_;
}
const sorted = [...state.favoriteFriends_];
sorted.sort(compareByName);
return sorted;
});
const favoriteWorlds = computed(() => {
if (appearanceSettingsStore.sortFavorites) {
return state.favoriteWorlds_;
}
const sorted = [...state.favoriteWorlds_];
sorted.sort(compareByName);
return sorted;
});
const favoriteAvatars = computed(() => {
if (appearanceSettingsStore.sortFavorites) {
return state.favoriteAvatars_;
}
const sorted = [...state.favoriteAvatars_];
sorted.sort(compareByName);
return sorted;
});
const isFavoriteGroupLoading = ref(false);
const favoriteFriendGroups = ref([]);
@@ -132,13 +86,31 @@ export const useFavoriteStore = defineStore('Favorite', () => {
currentGroup: {}
});
const cachedFavoritesByObjectId = computed(() => (objectId) => {
for (const item of cachedFavorites.values()) {
if (item.favoriteId === objectId) {
return item;
}
const favoriteFriends = computed(() => {
if (appearanceSettingsStore.sortFavorites) {
return state.favoriteFriends_;
}
return undefined;
const sorted = [...state.favoriteFriends_];
sorted.sort(compareByName);
return sorted;
});
const favoriteWorlds = computed(() => {
// if (appearanceSettingsStore.sortFavorites) {
return state.favoriteWorlds_;
// }
// const sorted = [...state.favoriteWorlds_];
// sorted.sort(compareByName);
// return sorted;
});
const favoriteAvatars = computed(() => {
if (appearanceSettingsStore.sortFavorites) {
return state.favoriteAvatars_;
}
const sorted = [...state.favoriteAvatars_];
sorted.sort(compareByName);
return sorted;
});
const localAvatarFavoriteGroups = computed(() =>
@@ -217,6 +189,34 @@ export const useFavoriteStore = defineStore('Favorite', () => {
{ flush: 'sync' }
);
function getCachedFavoriteGroupsByTypeName() {
const group = {};
for (const k in favoriteFriendGroups.value) {
const element = favoriteFriendGroups.value[k];
group[element.key] = element;
}
for (const k in favoriteWorldGroups.value) {
const element = favoriteWorldGroups.value[k];
group[element.key] = element;
}
for (const k in favoriteAvatarGroups.value) {
const element = favoriteAvatarGroups.value[k];
group[element.key] = element;
}
return group;
}
function getCachedFavoritesByObjectId(objectId) {
for (const item of cachedFavorites.values()) {
if (item.favoriteId === objectId) {
return item;
}
}
return undefined;
}
function handleFavoriteAdd(args) {
handleFavorite({
json: args.json,
@@ -264,7 +264,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
}
function handleFavoriteDelete(args) {
const ref = cachedFavoritesByObjectId.value(args.params.objectId);
const ref = getCachedFavoritesByObjectId(args.params.objectId);
if (typeof ref === 'undefined') {
return;
}
@@ -340,7 +340,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
*/
async function applyFavorite(type, objectId, sortTop = false) {
let ref;
const favorite = cachedFavoritesByObjectId.value(objectId);
const favorite = getCachedFavoritesByObjectId(objectId);
let ctx = state.favoriteObjects.get(objectId);
if (typeof favorite !== 'undefined') {
let isTypeChanged = false;
@@ -602,7 +602,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
// update favorites
for (ref of cachedFavorites.values()) {
group = cachedFavoriteGroupsByTypeName.value[ref.$groupKey];
group = getCachedFavoriteGroupsByTypeName()[ref.$groupKey];
if (typeof group === 'undefined') {
continue;
}
@@ -655,7 +655,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
done(ok) {
if (ok) {
for (const objectId of previousFavoriteIds) {
const fav = cachedFavoritesByObjectId.value(objectId);
const fav = getCachedFavoritesByObjectId(objectId);
if (!newFavoriteIds.has(objectId) && fav) {
handleFavoriteAtDelete(fav);
}
@@ -726,7 +726,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
friendStore.updateSidebarFavorites();
}
ref.$groupKey = `${ref.type}:${String(ref.tags[0])}`;
const group = cachedFavoriteGroupsByTypeName.value[ref.$groupKey];
const group = getCachedFavoriteGroupsByTypeName()[ref.$groupKey];
if (typeof group !== 'undefined') {
++group.count;
}
@@ -1190,7 +1190,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
avatarStore.avatarDialog.id === avatarId
) {
avatarStore.avatarDialog.isFavorite =
cachedFavoritesByObjectId.value(avatarId);
getCachedFavoritesByObjectId(avatarId);
}
// update UI
@@ -1317,7 +1317,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
worldStore.worldDialog.id === worldId
) {
worldStore.worldDialog.isFavorite =
cachedFavoritesByObjectId.value(worldId);
getCachedFavoritesByObjectId(worldId);
}
// update UI
@@ -1443,7 +1443,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
isFavoriteGroupLoading,
favoriteFriendGroups,
cachedFavoriteGroups,
cachedFavoriteGroupsByTypeName,
favoriteLimits,
cachedFavorites,
favoriteWorldGroups,
@@ -1461,7 +1460,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
localAvatarFavoriteGroups,
favoriteDialog,
localWorldFavoritesList,
cachedFavoritesByObjectId,
localWorldFavoriteGroups,
groupedByGroupKeyFavoriteFriends,
currentFavoriteTab,
@@ -1502,6 +1501,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
handleFavoriteGroupClear,
handleFavoriteGroup,
handleFavoriteDelete,
handleFavoriteAdd
handleFavoriteAdd,
getCachedFavoritesByObjectId
};
});
+1 -1
View File
@@ -242,7 +242,7 @@ export const useNotificationStore = defineStore('Notification', () => {
}
if (
generalSettingsStore.autoAcceptInviteRequests === 'All Favorites' &&
!favoriteStore.favoriteFriends.some(
!favoriteStore.state.favoriteFriends_.some(
(x) => x.id === ref.senderUserId
)
) {
+3 -1
View File
@@ -572,7 +572,9 @@ export const usePhotonStore = defineStore('Photon', () => {
hudTimeout.forEach((item) => {
if (
timeoutHudOverlayFilter.value === 'VIP' &&
favoriteStore.cachedFavoritesByObjectId(item.userId)
favoriteStore.getCachedFavoritesByObjectId(
item.userId
)
) {
filteredHudTimeout.push(item);
} else if (
+2 -3
View File
@@ -861,9 +861,8 @@ export const useUserStore = defineStore('User', () => {
}
}
}
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
D.id
);
D.isFavorite =
favoriteStore.getCachedFavoritesByObjectId(D.id);
if (D.ref.friendRequestStatus === 'incoming') {
D.incomingRequest = true;
} else if (D.ref.friendRequestStatus === 'outgoing') {
+2 -2
View File
@@ -262,7 +262,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
});
worldStore.cachedWorlds.forEach((ref, id) => {
if (
!favoriteStore.cachedFavoritesByObjectId(id) &&
!favoriteStore.getCachedFavoritesByObjectId(id) &&
ref.authorId !== userStore.currentUser.id &&
!favoriteStore.localWorldFavoritesList.includes(id)
) {
@@ -271,7 +271,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
});
avatarStore.cachedAvatars.forEach((ref, id) => {
if (
!favoriteStore.cachedFavoritesByObjectId(id) &&
!favoriteStore.getCachedFavoritesByObjectId(id) &&
ref.authorId !== userStore.currentUser.id &&
!favoriteStore.localAvatarFavoritesList.includes(id) &&
!avatarStore.avatarHistory.includes(id)
+1 -1
View File
@@ -142,7 +142,7 @@ export const useWorldStore = defineStore('World', () => {
if (D.id === args.ref.id) {
D.loading = false;
D.ref = args.ref;
D.isFavorite = favoriteStore.cachedFavoritesByObjectId(
D.isFavorite = favoriteStore.getCachedFavoritesByObjectId(
D.id
);
if (!D.isFavorite) {