Mutual friends tab

This commit is contained in:
Natsumi
2025-11-11 15:00:41 +11:00
parent 8789e05eb6
commit 4900432451
8 changed files with 261 additions and 9 deletions

View File

@@ -170,7 +170,7 @@ function compareByLastActive(a, b) {
b.ref?.$online_for &&
a.ref.$online_for === b.ref.$online_for
) {
compareByActivityField(a, b, 'last_login');
return compareByActivityField(a, b, 'last_login');
}
return compareByActivityField(a, b, '$online_for');
}
@@ -178,6 +178,16 @@ function compareByLastActive(a, b) {
return compareByActivityField(a, b, 'last_activity');
}
function compareByLastActiveRef(a, b) {
if (a.state === 'online' && b.state === 'online') {
if (a.$online_for && b.$online_for && a.$online_for === b.$online_for) {
return a.last_login < b.last_login ? 1 : -1;
}
return a.$online_for < b.$online_for ? 1 : -1;
}
return a.last_activity < b.last_activity ? 1 : -1;
}
/**
* last seen
* @param {object} a
@@ -259,6 +269,19 @@ function compareByLocation(a, b) {
return a.ref.location.localeCompare(b.ref.location);
}
/**
* $friendNumber friend order
* @param {object} a
* @param {object} b
* @returns
*/
function compareByFriendOrder(a, b) {
if (typeof a === 'undefined' || typeof b === 'undefined') {
return 0;
}
return b.$friendNumber - a.$friendNumber;
}
export {
compareByName,
compareByCreatedAt,
@@ -270,7 +293,9 @@ export {
compareByPrivate,
compareByStatus,
compareByLastActive,
compareByLastActiveRef,
compareByLastSeen,
compareByLocationAt,
compareByLocation
compareByLocation,
compareByFriendOrder
};