Copy tags on duplicating

This commit is contained in:
Cohee
2024-03-28 01:13:54 +02:00
parent 03582a8ec6
commit 6ed604593c
4 changed files with 34 additions and 9 deletions

View File

@ -48,16 +48,24 @@ class CharacterContextMenu {
* Duplicate one or more characters
*
* @param characterId
* @returns {Promise<Response>}
* @returns {Promise<any>}
*/
static duplicate = async (characterId) => {
const character = CharacterContextMenu.#getCharacter(characterId);
const body = { avatar_url: character.avatar };
return fetch('/api/characters/duplicate', {
const result = await fetch('/api/characters/duplicate', {
method: 'POST',
headers: getRequestHeaders(),
body: JSON.stringify({ avatar_url: character.avatar }),
body: JSON.stringify(),
});
if (!result.ok) {
throw new Error('Character not duplicated');
}
const data = await result.json();
await eventSource.emit(event_types.CHARACTER_DUPLICATED, { oldAvatar: body.avatar_url, newAvatar: data.path });
};
/**