mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into persona-lorebook
This commit is contained in:
@ -60,7 +60,6 @@ export {
|
||||
loadMovingUIState,
|
||||
collapseNewlines,
|
||||
playMessageSound,
|
||||
sortEntitiesList,
|
||||
fixMarkdown,
|
||||
power_user,
|
||||
send_on_enter_options,
|
||||
@ -474,9 +473,9 @@ function switchCompactInputArea() {
|
||||
$('#compact_input_area').prop('checked', power_user.compact_input_area);
|
||||
}
|
||||
|
||||
export function switchSwipeNumAllMessages() {
|
||||
function switchSwipeNumAllMessages() {
|
||||
$('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
|
||||
$('.mes:not(.last_mes) .swipes-counter').css('opacity', '').toggle(power_user.show_swipe_num_all_messages);
|
||||
$('body').toggleClass('swipeAllMessages', !!power_user.show_swipe_num_all_messages);
|
||||
}
|
||||
|
||||
var originalSliderValues = [];
|
||||
@ -1838,7 +1837,7 @@ async function loadContextSettings() {
|
||||
* Common function to perform fuzzy search with optional caching
|
||||
* @param {string} type - Type of search from fuzzySearchCategories
|
||||
* @param {any[]} data - Data array to search in
|
||||
* @param {Array<{name: string, weight: number, getFn?: Function}>} keys - Fuse.js keys configuration
|
||||
* @param {Array<{name: string, weight: number, getFn?: (obj: any) => string}>} keys - Fuse.js keys configuration
|
||||
* @param {string} searchValue - The search term
|
||||
* @param {Object.<string, { resultMap: Map<string, any> }>} [fuzzySearchCaches=null] - Optional fuzzy search caches
|
||||
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
|
||||
@ -1852,7 +1851,6 @@ function performFuzzySearch(type, data, keys, searchValue, fuzzySearchCaches = n
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const fuse = new Fuse(data, {
|
||||
keys: keys,
|
||||
includeScore: true,
|
||||
@ -2081,19 +2079,22 @@ const compareFunc = (first, second) => {
|
||||
/**
|
||||
* Sorts an array of entities based on the current sort settings
|
||||
* @param {any[]} entities An array of objects with an `item` property
|
||||
* @param {boolean} forceSearch Whether to force search sorting
|
||||
* @param {import('./filters.js').FilterHelper} [filterHelper=null] Filter helper to use
|
||||
*/
|
||||
function sortEntitiesList(entities) {
|
||||
export function sortEntitiesList(entities, forceSearch, filterHelper = null) {
|
||||
filterHelper = filterHelper ?? entitiesFilter;
|
||||
if (power_user.sort_field == undefined || entities.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (power_user.sort_order === 'random') {
|
||||
const isSearch = forceSearch || $('#character_sort_order option[data-field="search"]').is(':selected');
|
||||
|
||||
if (!isSearch && power_user.sort_order === 'random') {
|
||||
shuffle(entities);
|
||||
return;
|
||||
}
|
||||
|
||||
const isSearch = $('#character_sort_order option[data-field="search"]').is(':selected');
|
||||
|
||||
entities.sort((a, b) => {
|
||||
// Sort tags/folders will always be at the top
|
||||
if (a.type === 'tag' && b.type !== 'tag') {
|
||||
@ -2105,8 +2106,8 @@ function sortEntitiesList(entities) {
|
||||
|
||||
// If we have search sorting, we take scores and use those
|
||||
if (isSearch) {
|
||||
const aScore = entitiesFilter.getScore(FILTER_TYPES.SEARCH, `${a.type}.${a.id}`);
|
||||
const bScore = entitiesFilter.getScore(FILTER_TYPES.SEARCH, `${b.type}.${b.id}`);
|
||||
const aScore = filterHelper.getScore(FILTER_TYPES.SEARCH, `${a.type}.${a.id}`);
|
||||
const bScore = filterHelper.getScore(FILTER_TYPES.SEARCH, `${b.type}.${b.id}`);
|
||||
return (aScore - bScore);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user