world & group instance sorting

This commit is contained in:
Natsumi
2023-07-12 18:21:33 +12:00
parent 0b10406d87
commit 8d2850eeb2

View File

@@ -17089,9 +17089,6 @@ speechSynthesis.getVoices();
});
}
}
D.rooms.sort(function (a, b) {
return b.users.length - a.users.length || b.occupants - a.occupants;
});
if (D.fileSize === 'Loading') {
$app.getBundleDateSize(ref)
.then(({ createdAt, fileSize }) => {
@@ -17285,7 +17282,7 @@ speechSynthesis.getVoices();
friendCount: 0,
users: [],
shortName: '',
json: {}
ref: {}
};
}
}
@@ -17298,7 +17295,7 @@ speechSynthesis.getVoices();
friendCount: 0,
users: [],
shortName,
json: {}
ref: {}
};
}
var cachedCurrentUser = API.cachedUsers.get(API.currentUser.id);
@@ -17419,9 +17416,40 @@ speechSynthesis.getVoices();
room.ref = ref;
}
}
// sort by more friends, occupants
rooms.sort(function (a, b) {
return b.users.length - a.users.length || b.occupants - a.occupants;
// sort selected and current instance to top
if (
b.location === D.$location.tag ||
b.location === lastLocation$.tag
) {
// sort selected instance above current instance
if (a.location === D.$location.tag) {
return -1;
}
return 1;
}
if (
a.location === D.$location.tag ||
a.location === lastLocation$.tag
) {
// sort selected instance above current instance
if (b.location === D.$location.tag) {
return 1;
}
return -1;
}
// sort by number of users when no friends in instance
if (a.users.length === 0 && b.users.length === 0) {
if (a.ref?.n_users < b.ref?.n_users) {
return 1;
}
return -1;
}
// sort by number of friends in instance
if (a.users.length < b.users.length) {
return 1;
}
return -1;
});
D.rooms = rooms;
this.updateTimers();
@@ -17560,9 +17588,26 @@ speechSynthesis.getVoices();
});
}
}
// sort by more friends, occupants
rooms.sort(function (a, b) {
return b.users.length - a.users.length || b.occupants - a.occupants;
// sort current instance to top
if (b.location === currentLocation) {
return 1;
}
if (a.location === currentLocation) {
return -1;
}
// sort by number of users when no friends in instance
if (a.users.length === 0 && b.users.length === 0) {
if (a.ref?.n_users < b.ref?.n_users) {
return 1;
}
return -1;
}
// sort by number of friends in instance
if (a.users.length < b.users.length) {
return 1;
}
return -1;
});
D.instances = rooms;
this.updateTimers();