mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-10 17:10:14 +01:00
Fix sort by date
This commit is contained in:
parent
e2e32da4e6
commit
d81c94de0b
@ -1153,15 +1153,15 @@ const compareFunc = (first, second) => {
|
|||||||
return Math.random() > 0.5 ? 1 : -1;
|
return Math.random() > 0.5 ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const a = first[power_user.sort_field];
|
||||||
|
const b = second[power_user.sort_field];
|
||||||
|
|
||||||
|
if (power_user.sort_field === 'create_date') {
|
||||||
|
return sortMoments(timestampToMoment(b), timestampToMoment(a));
|
||||||
|
}
|
||||||
|
|
||||||
switch (power_user.sort_rule) {
|
switch (power_user.sort_rule) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
const a = first[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
|
||||||
@ -1169,9 +1169,9 @@ const compareFunc = (first, second) => {
|
|||||||
if (a === b) return 0; // Sort equal values normally
|
if (a === b) return 0; // Sort equal values normally
|
||||||
return a < b ? -1 : 1; // Sort non-boolean values normally
|
return a < b ? -1 : 1; // Sort non-boolean values normally
|
||||||
default:
|
default:
|
||||||
return typeof first[power_user.sort_field] == "string"
|
return typeof a == "string"
|
||||||
? first[power_user.sort_field].localeCompare(second[power_user.sort_field])
|
? a.localeCompare(b)
|
||||||
: first[power_user.sort_field] - second[power_user.sort_field];
|
: a - b;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2178,6 +2178,7 @@ app.post("/importcharacter", urlencodedParser, async function (request, response
|
|||||||
importRisuSprites(jsonData);
|
importRisuSprites(jsonData);
|
||||||
unsetFavFlag(jsonData);
|
unsetFavFlag(jsonData);
|
||||||
jsonData = readFromV2(jsonData);
|
jsonData = readFromV2(jsonData);
|
||||||
|
jsonData["create_date"] = humanizedISO8601DateTime();
|
||||||
png_name = getPngName(jsonData.data?.name || jsonData.name);
|
png_name = getPngName(jsonData.data?.name || jsonData.name);
|
||||||
let char = JSON.stringify(jsonData);
|
let char = JSON.stringify(jsonData);
|
||||||
charaWrite(defaultAvatarPath, char, png_name, response, { file_name: png_name });
|
charaWrite(defaultAvatarPath, char, png_name, response, { file_name: png_name });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user