Refactor preset handling and improve database snapshot logic
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
if($ShowRealmFrameStore.startsWith('preset')){
|
if($ShowRealmFrameStore.startsWith('preset')){
|
||||||
const predata = await downloadPreset(Number($ShowRealmFrameStore.split(':')[1]), 'return')
|
const predata = await downloadPreset(Number($ShowRealmFrameStore.split(':')[1]), 'return')
|
||||||
const encodedPredata = predata.buf
|
const encodedPredata = predata.buf
|
||||||
const encodedPredataName = new TextEncoder().encode(predata.data.name + '.risupreset')
|
const encodedPredataName = new TextEncoder().encode(predata.data.name + '.risup')
|
||||||
data = {
|
data = {
|
||||||
data: encodedPredata.buffer,
|
data: encodedPredata.buffer,
|
||||||
name: encodedPredataName.buffer
|
name: encodedPredataName.buffer
|
||||||
|
|||||||
@@ -345,18 +345,14 @@ export async function saveDb(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
let newSaveHash = ''
|
$state.snapshot(DBState?.db?.characters?.[selIdState])
|
||||||
newSaveHash += JSON.stringify(DBState?.db?.characters?.[selIdState])
|
|
||||||
for(const key in DBState.db){
|
for(const key in DBState.db){
|
||||||
if(key !== 'characters'){
|
if(key !== 'characters'){
|
||||||
newSaveHash += (DBState.db[key])
|
$state.snapshot(DBState.db[key])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newSaveHash !== oldSaveHash){
|
changed = true
|
||||||
changed = true
|
|
||||||
oldSaveHash = newSaveHash
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -456,6 +456,10 @@ export async function generateAIImage(genPrompt:string, currentChar:character, n
|
|||||||
input = input.replaceAll('{{risu_neg}}', neg)
|
input = input.replaceAll('{{risu_neg}}', neg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(inputKeys[j] === 'seed' && typeof input === 'number'){
|
||||||
|
input = Math.floor(Math.random() * 1000000000)
|
||||||
|
}
|
||||||
|
|
||||||
node.inputs[inputKeys[j]] = input
|
node.inputs[inputKeys[j]] = input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1626,14 +1626,15 @@ export async function downloadPreset(id:number, type:'json'|'risupreset'|'return
|
|||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const buf2 = await encodeRPack(buf)
|
||||||
|
|
||||||
if(type === 'risupreset'){
|
if(type === 'risupreset'){
|
||||||
const buf2 = await encodeRPack(buf)
|
|
||||||
downloadFile(pres.name + "_preset.risup", buf2)
|
downloadFile(pres.name + "_preset.risup", buf2)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return {
|
return {
|
||||||
data: pres,
|
data: pres,
|
||||||
buf
|
buf: buf2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user