Skip to content

Commit

Permalink
Merge pull request #1898 from get10101/fix/hide-collab-close-swipe-bu…
Browse files Browse the repository at this point in the history
…tton-with-open-trade

fix: Hide collab close swipe button when open position
  • Loading branch information
bonomat authored Jan 25, 2024
2 parents fab2d8b + e5ac0bc commit 09ef46d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
9 changes: 7 additions & 2 deletions mobile/lib/common/channel_status_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ class ChannelStatusNotifier extends ChangeNotifier implements Subscriber {
}

bool hasDlcChannel() {
return getChannelStatus() != ChannelStatus.Unknown ||
getChannelStatus() != ChannelStatus.NotOpen;
return getChannelStatus() != ChannelStatus.Unknown &&
getChannelStatus() != ChannelStatus.NotOpen &&
getChannelStatus() != ChannelStatus.Closing;
}

bool hasDlcChannelWithoutPosition() {
return hasDlcChannel() && getChannelStatus() != ChannelStatus.WithPosition;
}

bool canForceClose() {
Expand Down
37 changes: 1 addition & 36 deletions mobile/lib/common/settings/channel_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _ChannelScreenState extends State<ChannelScreen> {
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(
text:
"Your Lightning funds will return back to your on-chain wallet after some time. You will have to reopen the app at some point in the future so that your node can claim them back.\n\n"),
"Your off-chain funds will return back to your on-chain wallet after some time.\n\n"),
TextSpan(
text:
"If you had a position open your payout will arrive in your on-chain wallet soon after the expiry time. \n")
Expand All @@ -111,41 +111,6 @@ class _ChannelScreenState extends State<ChannelScreen> {
}
}

RichText getForceCloseChannelText(ChannelStatusNotifier channelStatusNotifier) {
if (!channelStatusNotifier.hasDlcChannel()) {
return RichText(
text: const TextSpan(
text:
"You do not have a channel! Go fund your wallet and create one! Then you can come back here and force-close it.",
style: TextStyle(fontSize: 18, color: Colors.black, letterSpacing: 0.4),
));
}

return RichText(
text: const TextSpan(
style: TextStyle(fontSize: 18, color: Colors.black, letterSpacing: 0.4),
children: [
TextSpan(
text: "Warning",
style: TextStyle(color: Colors.red, fontWeight: FontWeight.w600),
),
TextSpan(
text:
": Force-closing your channel should only be considered as a last resort if 10101 is not reachable.\n\n",
),
TextSpan(
text:
"It's always better to collaboratively close as it will also save transaction fees.\n\n"),
TextSpan(text: "If you "),
TextSpan(
text: "force-close", style: TextStyle(color: Colors.red, fontWeight: FontWeight.w600)),
TextSpan(text: ", you will have to pay the fees for going on-chain.\n\n"),
TextSpan(text: "Your funds can be claimed by your on-chain wallet after a while.\n\n"),
],
),
);
}

String channelStatusToString(ChannelStatus status) {
switch (status) {
case ChannelStatus.NotOpen:
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/common/settings/collab_close_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class _CollabCloseScreenState extends State<CollabCloseScreen> {
),
)),
Visibility(
visible: channelStatusNotifier.hasDlcChannel(),
visible: channelStatusNotifier.hasDlcChannelWithoutPosition(),
child: Container(
margin: const EdgeInsets.all(10),
child: ConfirmationSlider(
Expand Down

0 comments on commit 09ef46d

Please sign in to comment.