mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Backend for sorting by create date field
This commit is contained in:
@ -30,7 +30,7 @@ import {
|
|||||||
import { registerSlashCommand } from "./slash-commands.js";
|
import { registerSlashCommand } from "./slash-commands.js";
|
||||||
import { tokenizers } from "./tokenizers.js";
|
import { tokenizers } from "./tokenizers.js";
|
||||||
|
|
||||||
import { countOccurrences, delay, isOdd, resetScrollHeight } from "./utils.js";
|
import { countOccurrences, delay, isOdd, resetScrollHeight, sortMoments, timestampToMoment } from "./utils.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
loadPowerUserSettings,
|
loadPowerUserSettings,
|
||||||
@ -1165,6 +1165,11 @@ const compareFunc = (first, second) => {
|
|||||||
case 'boolean':
|
case 'boolean':
|
||||||
const a = first[power_user.sort_field];
|
const a = first[power_user.sort_field];
|
||||||
const b = second[power_user.sort_field];
|
const b = second[power_user.sort_field];
|
||||||
|
|
||||||
|
if (power_user.sort_field === 'create_date') {
|
||||||
|
return sortMoments(timestampToMoment(a), timestampToMoment(b));
|
||||||
|
}
|
||||||
|
|
||||||
if (a === true || a === 'true') return 1; // Prioritize 'true' or true
|
if (a === true || a === 'true') return 1; // Prioritize 'true' or true
|
||||||
if (b === true || b === 'true') return -1; // Prioritize 'true' or true
|
if (b === true || b === 'true') return -1; // Prioritize 'true' or true
|
||||||
if (a && !b) return -1; // Move truthy values to the end
|
if (a && !b) return -1; // Move truthy values to the end
|
||||||
|
Reference in New Issue
Block a user