mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-08 07:32:34 +01:00
Enable getPastCharacterChats to work with specific character ids
This commit is contained in:
parent
ba3966e148
commit
4692450975
@ -5921,20 +5921,23 @@ export async function getChatsFromFiles(data, isGroupChat) {
|
||||
* The function sends a POST request to the server to retrieve all chats for the character. It then
|
||||
* processes the received data, sorts it by the file name, and returns the sorted data.
|
||||
*
|
||||
* @param {null|number} [characterId=null] - When set, the function will use this character id instead of this_chid.
|
||||
*
|
||||
* @returns {Promise<Array>} - An array containing metadata of all past chats of the character, sorted
|
||||
* in descending order by file name. Returns `undefined` if the fetch request is unsuccessful.
|
||||
*/
|
||||
async function getPastCharacterChats() {
|
||||
if (!characters[this_chid]) return;
|
||||
export async function getPastCharacterChats(characterId = null) {
|
||||
characterId = characterId || this_chid;
|
||||
if (!characters[characterId]) return [];
|
||||
|
||||
const response = await fetch('/api/characters/chats', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ avatar_url: characters[this_chid].avatar }),
|
||||
body: JSON.stringify({ avatar_url: characters[characterId].avatar }),
|
||||
headers: getRequestHeaders(),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
|
||||
let data = await response.json();
|
||||
|
Loading…
Reference in New Issue
Block a user