Skip to content

Commit

Permalink
ZEUS-2062: LSP peer connect: make silent on Open Channel view
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Mar 25, 2024
1 parent 2e4d7cf commit e5faf77
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
47 changes: 29 additions & 18 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,20 @@ export default class ChannelsStore {
}

@action
resetOpenChannel = () => {
resetOpenChannel = (silent?: boolean) => {
this.loading = false;
this.error = false;
this.errorPeerConnect = false;
if (!silent) {
this.errorMsgPeer = null;
this.errorPeerConnect = false;
this.connectingToPeer = false;
this.peerSuccess = false;
}
this.errorMsgChannel = null;
this.errorMsgPeer = null;
this.output_index = null;
this.funding_txid_str = null;
this.openingChannel = false;
this.connectingToPeer = false;
this.errorOpenChannel = false;
this.peerSuccess = false;
this.channelSuccess = false;
this.channelRequest = null;
};
Expand Down Expand Up @@ -469,11 +471,12 @@ export default class ChannelsStore {
public connectPeer = async (
request: OpenChannelRequest,
perm?: boolean,
connectPeerOnly?: boolean
connectPeerOnly?: boolean,
silent?: boolean
) => {
this.resetOpenChannel();
this.resetOpenChannel(silent);
this.channelRequest = undefined;
this.connectingToPeer = true;
if (!silent) this.connectingToPeer = true;

if (!request.host) {
return await new Promise((resolve) => {
Expand All @@ -491,16 +494,20 @@ export default class ChannelsStore {
perm
})
.then(() => {
this.errorPeerConnect = false;
this.connectingToPeer = false;
this.errorMsgPeer = null;
if (!silent) {
this.errorPeerConnect = false;
this.connectingToPeer = false;
this.errorMsgPeer = null;
this.peerSuccess = true;
}
if (!connectPeerOnly) this.channelRequest = request;
this.peerSuccess = true;
resolve(true);
})
.catch((error: any) => {
this.connectingToPeer = false;
this.peerSuccess = false;
if (!silent) {
this.connectingToPeer = false;
this.peerSuccess = false;
}
this.channelSuccess = false;
// handle error
if (
Expand All @@ -510,13 +517,17 @@ export default class ChannelsStore {
if (!connectPeerOnly) {
this.channelRequest = request;
} else {
this.errorMsgPeer = error.toString();
this.errorPeerConnect = true;
if (!silent) {
this.errorMsgPeer = error.toString();
this.errorPeerConnect = true;
}
}
resolve(true);
} else {
this.errorMsgPeer = error.toString();
this.errorPeerConnect = true;
if (!silent) {
this.errorMsgPeer = error.toString();
this.errorPeerConnect = true;
}
reject(this.errorMsgPeer);
}
});
Expand Down
1 change: 1 addition & 0 deletions stores/LSPStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default class LSPStore {
local_funding_amount: ''
},
false,
true,
true
);
} catch (e) {}
Expand Down

0 comments on commit e5faf77

Please sign in to comment.