Skip to content

Commit

Permalink
Merge pull request #57 from getAlby/feat/listen-for-webln-enabled
Browse files Browse the repository at this point in the history
feat: listen for webln:enabled event
  • Loading branch information
rolznz authored Sep 25, 2023
2 parents 9eeb427 + 83c970b commit bcba915
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,18 @@ function loadConfig() {
}
}

function addEventListeners() {
window.addEventListener('webln:enabled', async () => {
if (!store.getState().connecting) {
// webln was enabled from outside
// TODO: use the same name and logic for figuring out what extension as the extension connector
await store.getState().connect({
connectorName: 'Extension',
connectorType: 'extension.generic',
});
}
});
}

loadConfig();
addEventListeners();

0 comments on commit bcba915

Please sign in to comment.