From b8fe674dd743d81a654656042b7a41dffbb5c38f Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 11 Apr 2023 19:16:05 +0300 Subject: [PATCH] fix: remove closed `websocket` --- nostr/nostr_client.py | 3 ++- static/js/index.js | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/nostr/nostr_client.py b/nostr/nostr_client.py index dfacf7c..ea78bac 100644 --- a/nostr/nostr_client.py +++ b/nostr/nostr_client.py @@ -22,6 +22,7 @@ class NostrClient: await self.send_req_queue.put(ValueError("Restarting NostrClient...")) await self.recieve_event_queue.put(ValueError("Restarting NostrClient...")) self.ws.close() + self.ws = None async def connect_to_nostrclient_ws( self, on_open: Callable, on_message: Callable @@ -68,7 +69,7 @@ class NostrClient: req = await self.send_req_queue.get() if isinstance(req, ValueError): running = False - logger.warning("Nostr Client stopping") + logger.warning(str(req)) else: self.ws.send(json.dumps(req)) except Exception as ex: diff --git a/static/js/index.js b/static/js/index.js index 96d1d0b..83bfac8 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -138,15 +138,21 @@ const merchant = async () => { } }, restartNostrConnection: async function () { - try { - await LNbits.api.request( - 'PUT', - '/nostrmarket/api/v1/restart', - this.g.user.wallets[0].adminkey + LNbits.utils + .confirmDialog( + 'Are you sure you want to reconnect to the nostrcient extension?' ) - } catch (error) { - LNbits.utils.notifyApiError(error) - } + .onOk(async () => { + try { + await LNbits.api.request( + 'PUT', + '/nostrmarket/api/v1/restart', + this.g.user.wallets[0].adminkey + ) + } catch (error) { + LNbits.utils.notifyApiError(error) + } + }) } }, created: async function () {