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