10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 05:03:53 +01:00

Save indexDB to window.indexDB automaticaly to avoid re-created it

This commit is contained in:
Mickaël Véril 2020-11-01 16:57:16 +01:00
parent de8648e5f1
commit 6eb8717f55
2 changed files with 5 additions and 1 deletions

View File

@ -126,7 +126,7 @@ draft: false
window.defaultDats = window.defaultDats.concat(sub)
}
window.indexDB = await indexDB.loadAsync()
await indexDB.loadAsync()
window.defaultDats = window.defaultDats.sort((datfA, datfB) => {
const exSetA = datfA.set
const exSetB = datfB.set

View File

@ -1,11 +1,15 @@
class indexDB {
static async loadAsync() {
if (window.indexDB) {
return window.indexDB
}
var db = new indexDB
const maxAge= (DebugMode.Enabled,0,600)
const text = await getTextFromFileUrlAsync("/data/index.yaml",{"Cache-Control":`max-age=${maxAge}`})
const myYaml = jsyaml.load(text);
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others));
window.indexDB=db
return db
}
}