sysend.js icon indicating copy to clipboard operation
sysend.js copied to clipboard

Use localstorage option in sysend

Open jkrajinovic opened this issue 3 years ago • 1 comments

Hi, great library.

It would be nice if we can tell sysend to use localStorage instead of BroadcastChannel throgh options.

The use case is offline web application that run from filesystem.

Thanks

jkrajinovic avatar Jun 10 '22 09:06 jkrajinovic

Do you mean file:// protocol or something else?

Does BroadcastChannel throw some kind of error when used from filesystem? If that's the case I can easily use localStorage as a fallback. With this you will not need to specify the option, it will work out of the box.

jcubic avatar Jun 10 '22 10:06 jcubic

I think that I can add this API:

sysend.setup({ mode: 'localStorage' });
// or
sysend.useLocalStorage();

jcubic avatar Aug 22 '22 08:08 jcubic

New API added in version 1.14.0

jcubic avatar Aug 22 '22 09:08 jcubic

Hi, yes file:// protocol exactly.

Sorry for not responding saw the comments only now.

BroadcastChannel didn't throw any errors as I remember.

I'll investigate and get back.

Thank you very much for this option.

jkrajinovic avatar Aug 22 '22 13:08 jkrajinovic

I just checked the file:// protocol and it works without issues. Just open demo.html in the browser.

jcubic avatar Aug 22 '22 13:08 jcubic

But the option will also be useful. I'll update the demo to be able to turn off BroadcastChannel for testing.

jcubic avatar Aug 22 '22 13:08 jcubic

I've updated the demo to allow to turn off the localStorage and fix the parsing of file:// protocol because it was giving a warning from the proxy iframe.

jcubic avatar Aug 22 '22 14:08 jcubic