Use filter order in group candidates list

41a3035a2ab31987ff2d76b3e97d20fa9d1aa1b6

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +11 -10Ignore whitespace
public/script.js+2 -2
@@ -1637,7 +1637,7 @@ export function getEntitiesList({ doFilter = false, doSort = true } = {}) {
16371637 subEntities = entitiesFilter.applyFilters(subEntities, { clearScoreCache: false, tempOverrides: { [FILTER_TYPES.FOLDER]: FILTER_STATES.UNDEFINED }, clearFuzzySearchCaches: false });
16381638 }
16391639 if (doSort) {
16401640 sortEntitiesList(subEntities, false);
16411641 }
16421642 entity.entities = subEntities;
16431643 entity.hidden = subCount - subEntities.length;
@@ -1665,7 +1665,7 @@ export function getEntitiesList({ doFilter = false, doSort = true } = {}) {
16651665
16661666 // Sort before returning if requested
16671667 if (doSort) {
16681668 sortEntitiesList(entities, false);
16691669 }
16701670 entitiesFilter.clearFuzzySearchCaches();
16711671 return entities;
public/scripts/group-chats.js+6 -5
@@ -1267,14 +1267,15 @@ function getGroupCharacters({ doFilter, onlyMembers } = {}) {
12671267 .filter((x) => isGroupMember(thisGroup, x.avatar) == onlyMembers)
12681268 .map((x, index) => ({ item: x, id: index, type: 'character' }));
12691269
1270+ if (doFilter) {
1271+ candidates = groupCandidatesFilter.applyFilters(candidates);
1272+ }
1273+
12701274 if (onlyMembers) {
12711275 candidates.sort(sortMembersFn);
12721276 } else {
1273- sortEntitiesList(candidates);
1277+ const useFilterOrder = doFilter && !!$('#rm_group_filter').val();
1274- }
1278+ sortEntitiesList(candidates, useFilterOrder);
1275-
1276- if (doFilter) {
1277- candidates = groupCandidatesFilter.applyFilters(candidates);
12781279 }
12791280
12801281 return candidates;
public/scripts/power-user.js+3 -3
@@ -60,7 +60,6 @@ export {
6060 loadMovingUIState,
6161 collapseNewlines,
6262 playMessageSound,
63- sortEntitiesList,
6463 fixMarkdown,
6564 power_user,
6665 send_on_enter_options,
@@ -2080,8 +2079,9 @@ const compareFunc = (first, second) => {
20802079/**
20812080 * Sorts an array of entities based on the current sort settings
20822081 * @param {any[]} entities An array of objects with an `item` property
2082+ * @param {boolean} forceSearch Whether to force search sorting
20832083 */
20842084export function sortEntitiesList(entities, forceSearch) {
20852085 if (power_user.sort_field == undefined || entities.length === 0) {
20862086 return;
20872087 }
@@ -2091,7 +2091,7 @@ function sortEntitiesList(entities) {
20912091 return;
20922092 }
20932093
20942094 const isSearch = forceSearch || $('#character_sort_order option[data-field="search"]').is(':selected');
20952095
20962096 entities.sort((a, b) => {
20972097 // Sort tags/folders will always be at the top