Make sorting of group instances stable (#1419)

This commit is contained in:
Bartłomiej Mazur
2025-10-14 19:15:15 +02:00
committed by GitHub
parent 5abb745b21
commit efc237164d
2 changed files with 26 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import { instanceContentSettings } from '../shared/constants';
import {
checkVRChatCache,
compareByDisplayName,
compareById,
compareByLocationAt,
displayLocation,
getAvailablePlatforms,
@@ -727,17 +728,21 @@ export const useInstanceStore = defineStore('Instance', () => {
return -1;
}
// sort by number of users when no friends in instance
if (a.users.length === 0 && b.users.length === 0) {
if (a.users.length === 0 && b.users.length === 0 && a.ref?.userCount !== b.ref?.userCount) {
if (a.ref?.userCount < b.ref?.userCount) {
return 1;
}
return -1;
}
// sort by number of friends in instance
if (a.users.length < b.users.length) {
return 1;
if (a.users.length !== b.users.length) {
if (a.users.length < b.users.length) {
return 1;
}
return -1;
}
return -1;
// sort by id
return compareById(a, b)
});
D.rooms = rooms;
}