Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hide collab close swipe button when open position #1898

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading