mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Merge pull request #49 from AustinKelsay/bugfix/bitcoin-connect-initialized-err
Handle fallback for component already initialized
This commit is contained in:
commit
6a4c37f57a
@ -12,7 +12,10 @@ let initialized = false;
|
|||||||
|
|
||||||
export async function initializeBitcoinConnect() {
|
export async function initializeBitcoinConnect() {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
try {
|
||||||
const { init } = await import('@getalby/bitcoin-connect-react');
|
const { init } = await import('@getalby/bitcoin-connect-react');
|
||||||
|
// Check if custom elements are already registered
|
||||||
|
if (!customElements.get('bc-balance')) {
|
||||||
init({
|
init({
|
||||||
appName: "PlebDevs",
|
appName: "PlebDevs",
|
||||||
filters: ["nwc"],
|
filters: ["nwc"],
|
||||||
@ -20,6 +23,14 @@ export async function initializeBitcoinConnect() {
|
|||||||
});
|
});
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// If the error is about custom element already being defined, we can ignore it
|
||||||
|
// as it means the component is already initialized
|
||||||
|
if (!error.message?.includes('has already been defined as a custom element')) {
|
||||||
|
console.error('Error initializing Bitcoin Connect:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const BitcoinConnectButton = () => {
|
const BitcoinConnectButton = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user