From 19a521121eae04d891859684c84be2d81c43c048 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 13 Nov 2022 14:33:07 +0300 Subject: [PATCH] book-keeping + revision of indexing... Signed-off-by: Alex A. Naanou --- pwiki/store/base.js | 36 +++++++++++++----------------------- pwiki2.js | 17 ++++++++++++++--- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/pwiki/store/base.js b/pwiki/store/base.js index 4d9e2bf..3e11c0b 100755 --- a/pwiki/store/base.js +++ b/pwiki/store/base.js @@ -406,10 +406,10 @@ module.BaseStore = { && path.startsWith(this.__cache_path__)){ return data } //*/ - var {tags, paths} = await data // remove obsolete tags... - this.__tags.options.remove.call(this, data, name, path) + data = await this.__tags.options.remove.call(this, data, name, path) // add... + var {tags, paths} = data paths[path] = new Set(update.tags) for(var tag of update.tags ?? []){ ;(tags[tag] = @@ -572,6 +572,8 @@ module.BaseStore = { // XXX EXPERIMENTAL... + // This keeps the changes between saves... + // // XXX see issues with indexedDB... // XXX not sure if we need this... // XXX need a persistent fast store of changes... @@ -603,13 +605,6 @@ module.BaseStore = { data.then(_get) : _get(data) }, - // XXX do we need this??? - 'journal-clear': function(data, name){ - this.__journal('clear') - this.__journal_db - && this.__journal_db.clear() - return data }, - // XXX these need to be persistent... update: async function(data, name, path, update){ var date = this.__journal_db ? @@ -628,24 +623,19 @@ module.BaseStore = { data.push([Date.now(), 'remove', path]) return data }, - // XXX clear the .__journal_db... save: async function(data, name){ - data = await data - data.push([Date.now(), 'save']) - if(this.__cache_path__){ - var path = this.__cache_path__ +'/'+ name+'_index' - this.update(path, {index: data}) } - return data}, - // XXX populate the .__journal_db??? + this.__journal_db + && this.__journal_db.clear() + return [] }, + // XXX if .__journal_db is not empty then need to apply it to the index??? load: async function(data, name){ - // load... - if(this.__cache_path__){ - var path = this.__cache_path__ +'/'+ name+'_index' - data = (await this.get(path) ?? {}).index ?? [] } + // XXX return data }, + reset: function(data, name){ - this.__cache_path__ - && this.delete(this.__cache_path__ +'/'+ name+'_index') }, }), + this.__journal_db + && this.__journal_db.clear() + return [] }, }), journal: function(){ return this.__journal('__call__', ...arguments)}, //*/ diff --git a/pwiki2.js b/pwiki2.js index ad66178..47ef329 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -26,6 +26,8 @@ * - server / replication target * - management * +* +* * XXX things that will help: * - async render (infinite scroll + search + large pages) * unresolved -> dom placeholder @@ -34,8 +36,14 @@ * - * * -* XXX ASAP: do/test IndexedDB journal "live" store... -* XXX BUG: .tags.tags seems to be broken -- no paths in sets... +* XXX index: need to disable index persistence on memory stores... +* XXX index: would be nice to somehow persistently auto-generate index id's... +* ...maybe: ":" or something similar... +* ...would be nice to have store ids... +* XXX .journal: needed to break the update recursion -- i.e. decouple +* index .update(..) handlers from stored page updates by first +* updating the journal and on a timer updating the .cache/ page... +* XXX do/test IndexedDB journal "live" store... * XXX BUG: indexedDB: .deleteDatabase(..) does not actually delete the * database from the list until reload. * this breaks trying to open a database with the same name again... @@ -387,11 +395,14 @@ * Architecture: * * store <-> index -* ^ +* ^ ^ +* | | +* +---------+ * | * page <--> renderer * ^ * | +* | * client * *