refactor: cleanup lore local activation

This commit is contained in:
bangonicdd
2025-02-24 17:00:48 +09:00
parent 0f1d243935
commit a45a3925c2

View File

@@ -37,37 +37,25 @@
let tokens = $state(0)
function isLocallyActivated(book: loreBook){
return getCurrentChat()?.localLore.some(e =>
e.id === book.id &&
e.alwaysActive
)
return book.id ? getCurrentChat()?.localLore.some(e => e.id === book.id) : false
}
function activateLocally(book: loreBook){
const chat = getCurrentChat()
let childLore: loreBook | undefined
if(!book.id){
book.id = v4()
}else{
childLore = chat.localLore.find(e => e.id === book.id)
}
if(childLore){
childLore.alwaysActive = true
}else{
childLore = {
key: '',
comment: '',
content: '',
mode: 'child',
insertorder: 100,
alwaysActive: true,
secondkey: '',
selective: false,
id: book.id,
}
chat.localLore.push(childLore)
const childLore: loreBook = {
key: '',
comment: '',
content: '',
mode: 'child',
insertorder: 100,
alwaysActive: true,
secondkey: '',
selective: false,
id: book.id,
}
getCurrentChat().localLore.push(childLore)
}
function deactivateLocally(book: loreBook){
if(!book.id) return