Hi Andreas

>
> you are right, I'll keep the encryption feature in my mind for some future
> version. Regarding the management of the different object stores I am a bit
> stuck wondering how to put that into the tiddlywiki archtitecture best.
> Perhaps you have another good hint for me ;-) Hope I'm not to annoying with
> all that questions... Here's what I'd like to to:
>
> - execute the window.indexeddb.open function (e.g. from startup of from a
> macro)
> - in the "onsuccess" callback for that function: read all objectStores and
> list them in a ControlPanel tiddler (adding buttons for move/delete on each
> item)
> - from the buttons: execute some javascript to do actions on indexeddb,
> also including callbacks which should then refresh the tiddler.
>
> I'm not sure how to integrate all this async callbacks. Perhaps you could
> point me out the direction? Are widgets want I want or is that not the
> right thing? If I understood it well, the messaging should help me, but I
> would have to work on the DOM directly, right? I was hoping I could just do
> some simple macros, but that wouldn't work at all with callbacks probably...
>

It is indeed a complex scenario: it's not just the asynchronousness,
there's also the need to get the UI working properly, which has quite a few
moving parts.

1. In the initialisation of the indexeddb sync adaptor:
1a. use the document.location to choose an indexedDB object store within a
standardised database
1b. delete any entries from indexeddb that correspond byte-for-byte with
existing tiddlers in the store
1c. start syncing writes to indexeddb
2. Create a new startup module that:
2a. Registers a widget message handler for "tm-list-indexeddb-stores" that
asynchronously reads the objectStores from indexeddb and creates a
description tiddler describing each one. One approach would be for the
message "param" parameter to contain the prefix to be used in naming the
descriptive tiddlers. For example, setting param to "$:/temp/store/" and an
objectStore called "foo" would create a descriptive tiddler called
"$:/temp/store/foo"
2b. Registers a widget message handler for "tm-load-indexeddb-store" that
asynchronously loads the objectStore named in the "param" parameter
3. Add a new control panel tab pane that presents a button labelled
"inspect browser indexeddb database" that sends "tm-list-indexeddb-stores".
It then lists tiddlers prefixed "$:/temp/store/"  through a template that
describes them as stores and provides a button that sends the message
"tm-load-indexeddb-store" for each object store
4. Optionally, display the new control panel tab in a modal at startup if
the indexedDB store is empty and there are other objectstores present

As I say, quite a lot of moving parts (I've probably forgotten at least one
bit, too), but they can be done bit-by-bit and are individually relatively
simple. The UI components are quite similar to the recently implemented
plugin library architecture (see
https://github.com/Jermolene/TiddlyWiki5/blob/master/core/ui/ControlPanel/Modals/AddPlugins.tid
)

>
> No worries, such a project is a good way to learn a lot about the
> tiddlywiki architecture ;-) I made a startup module to clean up the
> indexedDB, that's working fine now. Thanks for your hints.
>

Great, I hope it continues to be fun,

Best wishes

Jeremy



>
> Cheers
> Andreas
>



-- 
Jeremy Ruston
mailto:[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to