mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-09 07:54:26 +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
|
* 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.
|
* 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
|
* @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.
|
* in descending order by file name. Returns `undefined` if the fetch request is unsuccessful.
|
||||||
*/
|
*/
|
||||||
async function getPastCharacterChats() {
|
export async function getPastCharacterChats(characterId = null) {
|
||||||
if (!characters[this_chid]) return;
|
characterId = characterId || this_chid;
|
||||||
|
if (!characters[characterId]) return [];
|
||||||
|
|
||||||
const response = await fetch('/api/characters/chats', {
|
const response = await fetch('/api/characters/chats', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ avatar_url: characters[this_chid].avatar }),
|
body: JSON.stringify({ avatar_url: characters[characterId].avatar }),
|
||||||
headers: getRequestHeaders(),
|
headers: getRequestHeaders(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
Loading…
Reference in New Issue
Block a user