{
const option = await alertChatOptions()
switch(option){
case 0:{
const newChat = safeStructuredClone($state.snapshot(chara.chats[i]))
newChat.name = `Copy of ${newChat.name}`
chara.chats.unshift(newChat)
chara.chatPage = 0
chara.chats = chara.chats
break
}
case 1:{
const chat = chara.chats[i]
if(chat.bindedPersona){
const confirm = await alertConfirm(language.doYouWantToUnbindCurrentPersona)
if(confirm){
chat.bindedPersona = ''
alertNormal(language.personaUnbindedSuccess)
}
}
else{
const confirm = await alertConfirm(language.doYouWantToBindCurrentPersona)
if(confirm){
if(!DBState.db.personas[DBState.db.selectedPersona].id){
DBState.db.personas[DBState.db.selectedPersona].id = v4()
}
chat.bindedPersona = DBState.db.personas[DBState.db.selectedPersona].id
console.log(DBState.db.personas[DBState.db.selectedPersona])
alertNormal(language.personaBindedSuccess)
}
}
break
}
case 2:{
chara.chatPage = i
createMultiuserRoom()
}
}
}}>
{
editMode = !editMode
}}>
{
e.stopPropagation()
exportChat(i)
}}>
{
e.stopPropagation()
if(chara.chats.length === 1){
alertError(language.errors.onlyOneChat)
return
}
const d = await alertConfirm(`${language.removeConfirm}${chat.name}`)
if(d){
chara.chatPage = 0
$ReloadGUIPointer += 1
let chats = chara.chats
chats.splice(i, 1)
chara.chats = chats
}
}}>