reworked .names() and some fixes and tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-10-12 03:25:07 +03:00
parent 498536695f
commit 71be07be39
3 changed files with 12 additions and 30 deletions

View File

@ -76,6 +76,13 @@ Promise.all([
store.update('Stores/IndexedDB', {
__proto__: indexeddb.IndexedDBStore,
}),
store.update('Stores/memory', {
__proto__: basestore.MetaStore,
data: {
'': {text: 'memory store'},
moo: {text: 'moo'},
},
}),
/*/ XXX next testing...
store.next.update('NextPage', {

View File

@ -168,24 +168,15 @@ module.BaseStore = {
.concat((!local && (this.next || {}).paths) ?
this.next.paths()
: []) },
// local names...
__names: cached('names', async function(){
return this.__paths()
// XXX BUG: after caching this will ignore the local argument....
names: cached('names', async function(local=false){
return this.paths(local)
.iter()
.reduce(function(res, path){
var n = pwpath.basename(path)
if(!n.includes('*')){
(res[n] = res[n] ?? []).push(path) }
return res }, {}) }),
// XXX should this also be cached???
names: async function(local=false){
return {
...(!local && (this.next || {}).names ?
await this.next.names()
: {}),
...await this.__names(),
} },
// XXX sort paths based on search order into three groups:
// - non-system
@ -713,18 +704,6 @@ module.MetaStore = {
return object.parentCall(MetaStore.paths, this, ...arguments)
.iter()
.concat(stores) },
names: async function(){
var that = this
var res = await object.parentCall(MetaStore.names, this, ...arguments)
await Promise.all(Object.entries(this.substores ?? {})
.map(async function([path, store]){
return Object.entries(await store.names())
.map(function([name, paths]){
res[name] = (res[name] ?? [])
.concat(paths
.map(function(s){
return pwpath.join(path, s) })) }) }))
return res },
exists: metaProxy('exists',
//async function(path){

View File

@ -17,12 +17,8 @@
* - CLI
*
*
* XXX BUG: can't .get(..) data from substore root...
* ...updating it seems to work fine...
* XXX IndexedDB: after editing a page for some reason we do not see the
* final version until a full refresh -- cache???
* ...this seems to disappeared after moving external stores
* from / to /Stores...
* XXX BUG: when editing the root page of a substore the page's .cache is
* not reset for some reason...
* XXX Chrome started spamming CORS error:
* Access to manifest at 'file:///L:/work/pWiki/manifest.json'
* from origin 'null' ...