Enhance cold storage handling by updating chat data structure and ensuring compatibility with existing data formats
This commit is contained in:
@@ -215,12 +215,29 @@ export async function makeColdData(){
|
|||||||
|
|
||||||
if(greatestTime < coldTime){
|
if(greatestTime < coldTime){
|
||||||
const id = crypto.randomUUID()
|
const id = crypto.randomUUID()
|
||||||
await setColdStorageItem(id, chat.message)
|
await setColdStorageItem(id, {
|
||||||
|
message: chat.message,
|
||||||
|
hypaV2Data: chat.hypaV2Data,
|
||||||
|
hypaV3Data: chat.hypaV3Data,
|
||||||
|
scriptstate: chat.scriptstate,
|
||||||
|
localLore: chat.localLore
|
||||||
|
})
|
||||||
chat.message = [{
|
chat.message = [{
|
||||||
time: currentTime,
|
time: currentTime,
|
||||||
data: coldStorageHeader + id,
|
data: coldStorageHeader + id,
|
||||||
role: 'char'
|
role: 'char'
|
||||||
}]
|
}]
|
||||||
|
chat.hypaV2Data = {
|
||||||
|
chunks:[],
|
||||||
|
mainChunks: [],
|
||||||
|
lastMainChunkID: 0,
|
||||||
|
}
|
||||||
|
chat.hypaV3Data = {
|
||||||
|
summaries:[]
|
||||||
|
}
|
||||||
|
chat.scriptstate = {}
|
||||||
|
chat.localLore = []
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,10 +254,17 @@ export async function preLoadChat(characterIndex:number, chatIndex:number){
|
|||||||
//bring back from cold storage
|
//bring back from cold storage
|
||||||
const coldDataKey = chat.message[0].data.slice(coldStorageHeader.length)
|
const coldDataKey = chat.message[0].data.slice(coldStorageHeader.length)
|
||||||
const coldData = await getColdStorageItem(coldDataKey)
|
const coldData = await getColdStorageItem(coldDataKey)
|
||||||
if(coldData){
|
if(coldData && Array.isArray(coldData)){
|
||||||
chat.message = coldData
|
chat.message = coldData
|
||||||
chat.lastDate = Date.now()
|
chat.lastDate = Date.now()
|
||||||
}
|
}
|
||||||
|
else if(coldData){
|
||||||
|
chat.message = coldData.message
|
||||||
|
chat.hypaV2Data = coldData.hypaV2Data
|
||||||
|
chat.hypaV3Data = coldData.hypaV3Data
|
||||||
|
chat.scriptstate = coldData.scriptstate
|
||||||
|
chat.localLore = coldData.localLore
|
||||||
|
}
|
||||||
await setColdStorageItem(coldDataKey + '_accessMeta', {
|
await setColdStorageItem(coldDataKey + '_accessMeta', {
|
||||||
lastAccess: Date.now()
|
lastAccess: Date.now()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user