Some apps might take a while to load; we should probably have a loading screen.
I'd implement a small http://ricostacruz.com/nprogress/ kind of thing
Looking into this, getting an accurate progress bar is going to be difficult.
For now we can just fudge everything, but it might be a nice touch in the future if everything aligns 馃槃.
js-ipfs-api doesn't support a progress callback on ipfs.files.get() or ipfs.files.cat(), so an alternative could be to:
ipfs.ls() to find out the file sizes of the index.html, manifest.json, and the background script, if any,index.html needs, and add that as the iframe loading index.js fires its load event (or a "ready" event via postMessage(), given that we can't be 100% sure the iframe's ready to accept messages until it fires its own message).The above assumes that we can data URI encode a blob and use that as the iframe's source, but this still looks flaky in browsers. We can skip that by just setting the iframe's src to point to an ipfs gateway URL for the index.html and adjust the fudge factor.
We're not going to use those calls anyway; we'll load the file via HTTP directly from an IPFS node, so we need to hook into a progress event on the iframe, if possible :)
There's really only one progress event on the iframe, which is when everything on the page is loaded (including all images, scripts, etc), hence the fudging needed. Are we going to be loading the background script via HTTP directly too?
No but the background script should always run, so I don't think we need a loading screen for that.
Kinda sad for iframes, not really sure what to do about that right now, I'll investigate tomorrow 馃槉
Most helpful comment
Looking into this, getting an accurate progress bar is going to be difficult.
For now we can just fudge everything, but it might be a nice touch in the future if everything aligns 馃槃.
js-ipfs-api doesn't support a progress callback on
ipfs.files.get()oripfs.files.cat(), so an alternative could be to:ipfs.ls()to find out the file sizes of theindex.html,manifest.json, and the background script, if any,index.htmlneeds, and add that as the iframe loadingindex.jsfires itsloadevent (or a "ready" event viapostMessage(), given that we can't be 100% sure the iframe's ready to accept messages until it fires its own message).The above assumes that we can data URI encode a blob and use that as the iframe's source, but this still looks flaky in browsers. We can skip that by just setting the iframe's
srcto point to an ipfs gateway URL for theindex.htmland adjust the fudge factor.