joule-labs / webln

Spec and client library for WebLN apps and providers
244 stars 28 forks source link

Spec should include way to control prompts #29

Closed ianpatton closed 5 years ago

ianpatton commented 5 years ago

the spec should provide a way of controlling the prompts that are being displayed.

The provider could keep an array of open prompts, which would allow for the following methods to be exposed:

enum PromptTypes { enable = "enable", getInfo = "getInfo", sendPayment = "sendPayment", ... }

interface PromptObject { promptType: PromptTypes; id: string; }

(Assigning a unique Id in the prompt object allows them to be closed without worrying about things shifting.)

This would help with issues like: https://github.com/joule-labs/joule-extension/issues/232, where the app itself may have more context on the payment than the LND node you are connected to.

It would also help prevent issues where the app may stack up several requests that do not get acknowledged right away, allowing the app to replace the current prompt instead of stacking them.

wbobeirne commented 5 years ago

This seems pretty harmless, but it is somewhat Joule-centric (Some WebLN providers might completely background the screen while the prompt is active, like on a mobile app) and adds a decent amount of complexity to being a WebLN provider. I think the ideal scenario is to just make issues like the one linked to with Joule less of a problem.

As for stacking requests, that's also another issue I think Joule should be better about. It should either instantly throw if you request too quickly again, or replace the existing window with the new request, instead of opening a new window.

Happy to work with you on the Joule front to ease any issues, I'd like to avoid putting a burden on other developers for any issues that are a problem with Joule specifically.