mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
Fix local favorites sort order
This commit is contained in:
+11
-56
@@ -65,14 +65,8 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
localWorldFavoriteGroups: [],
|
localWorldFavoriteGroups: [],
|
||||||
localWorldFavoritesList: [],
|
localWorldFavoritesList: [],
|
||||||
favoriteFriends_: [],
|
favoriteFriends_: [],
|
||||||
favoriteFriendsSorted: [],
|
|
||||||
favoriteWorlds_: [],
|
favoriteWorlds_: [],
|
||||||
favoriteWorldsSorted: [],
|
|
||||||
favoriteAvatars_: [],
|
favoriteAvatars_: [],
|
||||||
favoriteAvatarsSorted: [],
|
|
||||||
sortFavoriteFriends: false,
|
|
||||||
sortFavoriteWorlds: false,
|
|
||||||
sortFavoriteAvatars: false,
|
|
||||||
cachedFavoritesByObjectId: new Map()
|
cachedFavoritesByObjectId: new Map()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,36 +86,30 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const favoriteFriends = computed(() => {
|
const favoriteFriends = computed(() => {
|
||||||
if (state.sortFavoriteFriends) {
|
|
||||||
state.sortFavoriteFriends = false;
|
|
||||||
state.favoriteFriendsSorted.sort(compareByName);
|
|
||||||
}
|
|
||||||
if (appearanceSettingsStore.sortFavorites) {
|
if (appearanceSettingsStore.sortFavorites) {
|
||||||
return state.favoriteFriends_;
|
return state.favoriteFriends_;
|
||||||
}
|
}
|
||||||
return state.favoriteFriendsSorted;
|
const sorted = [...state.favoriteFriends_];
|
||||||
|
sorted.sort(compareByName);
|
||||||
|
return sorted;
|
||||||
});
|
});
|
||||||
|
|
||||||
const favoriteWorlds = computed(() => {
|
const favoriteWorlds = computed(() => {
|
||||||
if (state.sortFavoriteWorlds) {
|
|
||||||
state.sortFavoriteWorlds = false;
|
|
||||||
state.favoriteWorldsSorted.sort(compareByName);
|
|
||||||
}
|
|
||||||
if (appearanceSettingsStore.sortFavorites) {
|
if (appearanceSettingsStore.sortFavorites) {
|
||||||
return state.favoriteWorlds_;
|
return state.favoriteWorlds_;
|
||||||
}
|
}
|
||||||
return state.favoriteWorldsSorted;
|
const sorted = [...state.favoriteWorlds_];
|
||||||
|
sorted.sort(compareByName);
|
||||||
|
return sorted;
|
||||||
});
|
});
|
||||||
|
|
||||||
const favoriteAvatars = computed(() => {
|
const favoriteAvatars = computed(() => {
|
||||||
if (state.sortFavoriteAvatars) {
|
|
||||||
state.sortFavoriteAvatars = false;
|
|
||||||
state.favoriteAvatarsSorted.sort(compareByName);
|
|
||||||
}
|
|
||||||
if (appearanceSettingsStore.sortFavorites) {
|
if (appearanceSettingsStore.sortFavorites) {
|
||||||
return state.favoriteAvatars_;
|
return state.favoriteAvatars_;
|
||||||
}
|
}
|
||||||
return state.favoriteAvatarsSorted;
|
const sorted = [...state.favoriteAvatars_];
|
||||||
|
sorted.sort(compareByName);
|
||||||
|
return sorted;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isFavoriteGroupLoading = computed({
|
const isFavoriteGroupLoading = computed({
|
||||||
@@ -330,14 +318,8 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
state.isFavoriteGroupLoading = false;
|
state.isFavoriteGroupLoading = false;
|
||||||
state.favoriteObjects.clear();
|
state.favoriteObjects.clear();
|
||||||
state.favoriteFriends_ = [];
|
state.favoriteFriends_ = [];
|
||||||
state.favoriteFriendsSorted = [];
|
|
||||||
state.favoriteWorlds_ = [];
|
state.favoriteWorlds_ = [];
|
||||||
state.favoriteWorldsSorted = [];
|
|
||||||
state.favoriteAvatars_ = [];
|
state.favoriteAvatars_ = [];
|
||||||
state.favoriteAvatarsSorted = [];
|
|
||||||
state.sortFavoriteFriends = false;
|
|
||||||
state.sortFavoriteWorlds = false;
|
|
||||||
state.sortFavoriteAvatars = false;
|
|
||||||
state.localAvatarFavoriteGroups = [];
|
state.localAvatarFavoriteGroups = [];
|
||||||
state.localAvatarFavoritesList = [];
|
state.localAvatarFavoritesList = [];
|
||||||
state.localAvatarFavorites = {};
|
state.localAvatarFavorites = {};
|
||||||
@@ -497,11 +479,8 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
state.cachedFavoritesByObjectId.clear();
|
state.cachedFavoritesByObjectId.clear();
|
||||||
state.favoriteObjects.clear();
|
state.favoriteObjects.clear();
|
||||||
state.favoriteFriends_ = [];
|
state.favoriteFriends_ = [];
|
||||||
state.favoriteFriendsSorted = [];
|
|
||||||
state.favoriteWorlds_ = [];
|
state.favoriteWorlds_ = [];
|
||||||
state.favoriteWorldsSorted = [];
|
|
||||||
state.favoriteAvatars_ = [];
|
state.favoriteAvatars_ = [];
|
||||||
state.favoriteAvatarsSorted = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFavoriteAtDelete(args) {
|
function handleFavoriteAtDelete(args) {
|
||||||
@@ -598,13 +577,10 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
isTypeChanged = true;
|
isTypeChanged = true;
|
||||||
if (type === 'friend') {
|
if (type === 'friend') {
|
||||||
removeFromArray(state.favoriteFriends_, ctx);
|
removeFromArray(state.favoriteFriends_, ctx);
|
||||||
removeFromArray(state.favoriteFriendsSorted, ctx);
|
|
||||||
} else if (type === 'world') {
|
} else if (type === 'world') {
|
||||||
removeFromArray(state.favoriteWorlds_, ctx);
|
removeFromArray(state.favoriteWorlds_, ctx);
|
||||||
removeFromArray(state.favoriteWorldsSorted, ctx);
|
|
||||||
} else if (type === 'avatar') {
|
} else if (type === 'avatar') {
|
||||||
removeFromArray(state.favoriteAvatars_, ctx);
|
removeFromArray(state.favoriteAvatars_, ctx);
|
||||||
removeFromArray(state.favoriteAvatarsSorted, ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === 'friend') {
|
if (type === 'friend') {
|
||||||
@@ -615,7 +591,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
}
|
}
|
||||||
if (ctx.name !== ref.displayName) {
|
if (ctx.name !== ref.displayName) {
|
||||||
ctx.name = ref.displayName;
|
ctx.name = ref.displayName;
|
||||||
state.sortFavoriteFriends = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else too bad
|
// else too bad
|
||||||
@@ -627,7 +602,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
}
|
}
|
||||||
if (ctx.name !== ref.name) {
|
if (ctx.name !== ref.name) {
|
||||||
ctx.name = ref.name;
|
ctx.name = ref.name;
|
||||||
state.sortFavoriteWorlds = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try fetch from local world favorites
|
// try fetch from local world favorites
|
||||||
@@ -637,7 +611,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
ctx.ref = world;
|
ctx.ref = world;
|
||||||
ctx.name = world.name;
|
ctx.name = world.name;
|
||||||
ctx.deleted = true;
|
ctx.deleted = true;
|
||||||
state.sortFavoriteWorlds = true;
|
|
||||||
}
|
}
|
||||||
if (!world) {
|
if (!world) {
|
||||||
// try fetch from local world history
|
// try fetch from local world history
|
||||||
@@ -648,7 +621,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
if (worldName) {
|
if (worldName) {
|
||||||
ctx.name = worldName;
|
ctx.name = worldName;
|
||||||
ctx.deleted = true;
|
ctx.deleted = true;
|
||||||
state.sortFavoriteWorlds = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,7 +632,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
}
|
}
|
||||||
if (ctx.name !== ref.name) {
|
if (ctx.name !== ref.name) {
|
||||||
ctx.name = ref.name;
|
ctx.name = ref.name;
|
||||||
state.sortFavoriteAvatars = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try fetch from local avatar history
|
// try fetch from local avatar history
|
||||||
@@ -670,7 +641,6 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
ctx.ref = avatar;
|
ctx.ref = avatar;
|
||||||
ctx.name = avatar.name;
|
ctx.name = avatar.name;
|
||||||
ctx.deleted = true;
|
ctx.deleted = true;
|
||||||
state.sortFavoriteAvatars = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -679,42 +649,27 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
if (sortTop) {
|
if (sortTop) {
|
||||||
if (type === 'friend') {
|
if (type === 'friend') {
|
||||||
state.favoriteFriends_.unshift(ctx);
|
state.favoriteFriends_.unshift(ctx);
|
||||||
state.favoriteFriendsSorted.push(ctx);
|
|
||||||
state.sortFavoriteFriends = true;
|
|
||||||
} else if (type === 'world') {
|
} else if (type === 'world') {
|
||||||
state.favoriteWorlds_.unshift(ctx);
|
state.favoriteWorlds_.unshift(ctx);
|
||||||
state.favoriteWorldsSorted.push(ctx);
|
|
||||||
state.sortFavoriteWorlds = true;
|
|
||||||
} else if (type === 'avatar') {
|
} else if (type === 'avatar') {
|
||||||
state.favoriteAvatars_.unshift(ctx);
|
state.favoriteAvatars_.unshift(ctx);
|
||||||
state.favoriteAvatarsSorted.push(ctx);
|
|
||||||
state.sortFavoriteAvatars = true;
|
|
||||||
}
|
}
|
||||||
} else if (type === 'friend') {
|
} else if (type === 'friend') {
|
||||||
state.favoriteFriends_.push(ctx);
|
state.favoriteFriends_.push(ctx);
|
||||||
state.favoriteFriendsSorted.push(ctx);
|
|
||||||
state.sortFavoriteFriends = true;
|
|
||||||
} else if (type === 'world') {
|
} else if (type === 'world') {
|
||||||
state.favoriteWorlds_.push(ctx);
|
state.favoriteWorlds_.push(ctx);
|
||||||
state.favoriteWorldsSorted.push(ctx);
|
|
||||||
state.sortFavoriteWorlds = true;
|
|
||||||
} else if (type === 'avatar') {
|
} else if (type === 'avatar') {
|
||||||
state.favoriteAvatars_.push(ctx);
|
state.favoriteAvatars_.push(ctx);
|
||||||
state.favoriteAvatarsSorted.push(ctx);
|
|
||||||
state.sortFavoriteAvatars = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (typeof ctx !== 'undefined') {
|
} else if (typeof ctx !== 'undefined') {
|
||||||
state.favoriteObjects.delete(objectId);
|
state.favoriteObjects.delete(objectId);
|
||||||
if (type === 'friend') {
|
if (type === 'friend') {
|
||||||
removeFromArray(state.favoriteFriends_, ctx);
|
removeFromArray(state.favoriteFriends_, ctx);
|
||||||
removeFromArray(state.favoriteFriendsSorted, ctx);
|
|
||||||
} else if (type === 'world') {
|
} else if (type === 'world') {
|
||||||
removeFromArray(state.favoriteWorlds_, ctx);
|
removeFromArray(state.favoriteWorlds_, ctx);
|
||||||
removeFromArray(state.favoriteWorldsSorted, ctx);
|
|
||||||
} else if (type === 'avatar') {
|
} else if (type === 'avatar') {
|
||||||
removeFromArray(state.favoriteAvatars_, ctx);
|
removeFromArray(state.favoriteAvatars_, ctx);
|
||||||
removeFromArray(state.favoriteAvatarsSorted, ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1474,7 +1429,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
ref = { id: favorite.avatarId };
|
ref = { id: favorite.avatarId };
|
||||||
}
|
}
|
||||||
localFavorites[favorite.groupName].push(ref);
|
localFavorites[favorite.groupName].unshift(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
let groupsArr = Array.from(localGroups);
|
let groupsArr = Array.from(localGroups);
|
||||||
@@ -1714,7 +1669,7 @@ export const useFavoriteStore = defineStore('Favorite', () => {
|
|||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
ref = { id: favorite.worldId };
|
ref = { id: favorite.worldId };
|
||||||
}
|
}
|
||||||
localFavorites[favorite.groupName].push(ref);
|
localFavorites[favorite.groupName].unshift(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
let groupsArr = Array.from(localGroups);
|
let groupsArr = Array.from(localGroups);
|
||||||
|
|||||||
Reference in New Issue
Block a user