mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Make sorting of group instances stable (#1419)
This commit is contained in:
@@ -89,6 +89,22 @@ function compareByDisplayName(a, b) {
|
|||||||
return a.displayName.localeCompare(b.displayName);
|
return a.displayName.localeCompare(b.displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ascending
|
||||||
|
* @param {object} a
|
||||||
|
* @param {object} b
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function compareById(a, b) {
|
||||||
|
if (
|
||||||
|
typeof a.id !== 'string' ||
|
||||||
|
typeof b.id !== 'string'
|
||||||
|
) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return a.id.localeCompare(b.id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {object} a
|
* @param {object} a
|
||||||
@@ -252,6 +268,7 @@ export {
|
|||||||
compareByCreatedAtAscending,
|
compareByCreatedAtAscending,
|
||||||
compareByUpdatedAt,
|
compareByUpdatedAt,
|
||||||
compareByDisplayName,
|
compareByDisplayName,
|
||||||
|
compareById,
|
||||||
compareByMemberCount,
|
compareByMemberCount,
|
||||||
compareByPrivate,
|
compareByPrivate,
|
||||||
compareByStatus,
|
compareByStatus,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { instanceContentSettings } from '../shared/constants';
|
|||||||
import {
|
import {
|
||||||
checkVRChatCache,
|
checkVRChatCache,
|
||||||
compareByDisplayName,
|
compareByDisplayName,
|
||||||
|
compareById,
|
||||||
compareByLocationAt,
|
compareByLocationAt,
|
||||||
displayLocation,
|
displayLocation,
|
||||||
getAvailablePlatforms,
|
getAvailablePlatforms,
|
||||||
@@ -727,17 +728,21 @@ export const useInstanceStore = defineStore('Instance', () => {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// sort by number of users when no friends in instance
|
// 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) {
|
if (a.ref?.userCount < b.ref?.userCount) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// sort by number of friends in instance
|
// sort by number of friends in instance
|
||||||
if (a.users.length < b.users.length) {
|
if (a.users.length !== b.users.length) {
|
||||||
return 1;
|
if (a.users.length < b.users.length) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return -1;
|
// sort by id
|
||||||
|
return compareById(a, b)
|
||||||
});
|
});
|
||||||
D.rooms = rooms;
|
D.rooms = rooms;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user