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 } = {}) {
1637 subEntities = entitiesFilter.applyFilters(subEntities, { clearScoreCache: false, tempOverrides: { [FILTER_TYPES.FOLDER]: FILTER_STATES.UNDEFINED }, clearFuzzySearchCaches: false });1637 subEntities = entitiesFilter.applyFilters(subEntities, { clearScoreCache: false, tempOverrides: { [FILTER_TYPES.FOLDER]: FILTER_STATES.UNDEFINED }, clearFuzzySearchCaches: false });
1638 }1638 }
1639 if (doSort) {1639 if (doSort) {
1640 sortEntitiesList(subEntities);1640 sortEntitiesList(subEntities, false);
1641 }1641 }
1642 entity.entities = subEntities;1642 entity.entities = subEntities;
1643 entity.hidden = subCount - subEntities.length;1643 entity.hidden = subCount - subEntities.length;
@@ -1665,7 +1665,7 @@ export function getEntitiesList({ doFilter = false, doSort = true } = {}) {
16651665
1666 // Sort before returning if requested1666 // Sort before returning if requested
1667 if (doSort) {1667 if (doSort) {
1668 sortEntitiesList(entities);1668 sortEntitiesList(entities, false);
1669 }1669 }
1670 entitiesFilter.clearFuzzySearchCaches();1670 entitiesFilter.clearFuzzySearchCaches();
1671 return entities;1671 return entities;
public/scripts/group-chats.js+6 -5
@@ -1267,14 +1267,15 @@ function getGroupCharacters({ doFilter, onlyMembers } = {}) {
1267 .filter((x) => isGroupMember(thisGroup, x.avatar) == onlyMembers)1267 .filter((x) => isGroupMember(thisGroup, x.avatar) == onlyMembers)
1268 .map((x, index) => ({ item: x, id: index, type: 'character' }));1268 .map((x, index) => ({ item: x, id: index, type: 'character' }));
12691269
1270 if (doFilter) {
1271 candidates = groupCandidatesFilter.applyFilters(candidates);
1272 }
1273
1270 if (onlyMembers) {1274 if (onlyMembers) {
1271 candidates.sort(sortMembersFn);1275 candidates.sort(sortMembersFn);
1272 } else {1276 } 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);
1278 }1279 }
12791280
1280 return candidates;1281 return candidates;
public/scripts/power-user.js+3 -3
@@ -60,7 +60,6 @@ export {
60 loadMovingUIState,60 loadMovingUIState,
61 collapseNewlines,61 collapseNewlines,
62 playMessageSound,62 playMessageSound,
63 sortEntitiesList,
64 fixMarkdown,63 fixMarkdown,
65 power_user,64 power_user,
66 send_on_enter_options,65 send_on_enter_options,
@@ -2080,8 +2079,9 @@ const compareFunc = (first, second) => {
2080/**2079/**
2081 * Sorts an array of entities based on the current sort settings2080 * Sorts an array of entities based on the current sort settings
2082 * @param {any[]} entities An array of objects with an `item` property2081 * @param {any[]} entities An array of objects with an `item` property
2082 * @param {boolean} forceSearch Whether to force search sorting
2083 */2083 */
2084function sortEntitiesList(entities) {2084export function sortEntitiesList(entities, forceSearch) {
2085 if (power_user.sort_field == undefined || entities.length === 0) {2085 if (power_user.sort_field == undefined || entities.length === 0) {
2086 return;2086 return;
2087 }2087 }
@@ -2091,7 +2091,7 @@ function sortEntitiesList(entities) {
2091 return;2091 return;
2092 }2092 }
20932093
2094 const isSearch = $('#character_sort_order option[data-field="search"]').is(':selected');2094 const isSearch = forceSearch || $('#character_sort_order option[data-field="search"]').is(':selected');
20952095
2096 entities.sort((a, b) => {2096 entities.sort((a, b) => {
2097 // Sort tags/folders will always be at the top2097 // Sort tags/folders will always be at the top