Emit `PERSONA_CREATED` event on persona duplication (#5448) * feat: emit PERSONA_CREATED event when duplicating a persona Adds PERSONA_CREATED event emission in duplicatePersona() to notify listeners when a persona is duplicated. Includes the new avatarId, name, and duplicatedFromAvatarId in the event payload. * fix: event data and execution order --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -1827,6 +1827,16 @@ async function duplicatePersona(avatarId) { | ||
| 1827 | 1827 | }; |
| 1828 | 1828 | |
| 1829 | 1829 | await uploadUserAvatar(getUserAvatar(avatarId), newAvatarId); |
| 1830 | + | |
| 1831 | + const eventData = { | |
| 1832 | + avatarId: newAvatarId, | |
| 1833 | + name: personaName, | |
| 1834 | + description: descriptor?.description ?? '', | |
| 1835 | + title: descriptor?.title ?? '', | |
| 1836 | + duplicatedFromAvatarId: avatarId, | |
| 1837 | + }; | |
| 1838 | + await eventSource.emit(event_types.PERSONA_CREATED, eventData); | |
| 1839 | + | |
| 1830 | 1840 | await getUserAvatars(true, newAvatarId); |
| 1831 | 1841 | saveSettingsDebounced(); |
| 1832 | 1842 | } |