Skip to content

Commit cc2d099

Browse files
committed
fix(status): report payjoin as disabled, not offline, when off
Adds ServiceStatus.disabled (intentionally turned off, distinct from unknown/not-checked) and returns it for the payjoin service the moment the setting is off, instead of probing the OHTTP relay and painting the whole status page red for a feature the user isn't relying on. The status page shows it muted-grey with a "Disabled" label, and it no longer counts against allServicesOnline.
1 parent dce27f4 commit cc2d099

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

lib/core/status/domain/entity/service_status.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import 'package:freezed_annotation/freezed_annotation.dart';
22

33
part 'service_status.freezed.dart';
44

5-
enum ServiceStatus { online, offline, unknown }
5+
/// [disabled]: the service is intentionally turned off by the user (e.g.
6+
/// payjoin off in settings), so it is neither reachable-checked nor a
7+
/// problem — distinct from [unknown] (not checked / indeterminate).
8+
enum ServiceStatus { online, offline, unknown, disabled }
69

710
@freezed
811
sealed class ServiceStatusInfo with _$ServiceStatusInfo {
@@ -17,6 +20,7 @@ sealed class ServiceStatusInfo with _$ServiceStatusInfo {
1720
bool get isOnline => status == ServiceStatus.online;
1821
bool get isOffline => status == ServiceStatus.offline;
1922
bool get isUnknown => status == ServiceStatus.unknown;
23+
bool get isDisabled => status == ServiceStatus.disabled;
2024
}
2125

2226
@freezed
@@ -112,7 +116,8 @@ sealed class AllServicesStatus with _$AllServicesStatus {
112116
bitcoinElectrum.isOnline &&
113117
liquidElectrum.isOnline &&
114118
boltz.isOnline &&
115-
payjoin.isOnline &&
119+
// Payjoin is opt-in: disabled is not a fault (see _checkPayjoinService).
120+
(payjoin.isOnline || payjoin.isDisabled) &&
116121
pricer.isOnline &&
117122
mempool.isOnline &&
118123
(tor.isOnline || tor.isUnknown) &&

lib/core/status/domain/usecases/check_all_service_status_usecase.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ class CheckAllServiceStatusUsecase {
146146

147147
Future<ServiceStatusInfo> _checkPayjoinService() async {
148148
try {
149+
// Payjoin is opt-in: when it's disabled in settings the OHTTP relay is
150+
// not in use, so report `disabled` (not `offline`/red) — probing a
151+
// relay the user isn't relying on and painting the whole status page
152+
// red for it is misleading.
153+
final settings = await _settingsRepository.fetch();
154+
if (!settings.isPayjoinEnabled) {
155+
return ServiceStatusInfo(
156+
status: ServiceStatus.disabled,
157+
name: 'Payjoin',
158+
lastChecked: DateTime.now(),
159+
);
160+
}
161+
149162
final isHealthy = await _payjoinRepository.checkOhttpRelayHealth();
150163

151164
return ServiceStatusInfo(

lib/features/status_check/service_status_page.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class _ServiceStatusItem extends StatelessWidget {
137137
case ServiceStatus.offline:
138138
return context.appColors.error;
139139
case ServiceStatus.unknown:
140+
case ServiceStatus.disabled:
140141
return context.appColors.textMuted;
141142
}
142143
}
@@ -149,6 +150,8 @@ class _ServiceStatusItem extends StatelessWidget {
149150
return context.loc.statusCheckOffline;
150151
case ServiceStatus.unknown:
151152
return context.loc.statusCheckUnknown;
153+
case ServiceStatus.disabled:
154+
return context.loc.statusCheckDisabled;
152155
}
153156
}
154157
}

localization/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14887,5 +14887,9 @@
1488714887
"receivePayjoinActivated": "Payjoin activated",
1488814888
"@receivePayjoinActivated": {
1488914889
"description": "Message indicating that payjoin is activated for the receive transaction"
14890+
},
14891+
"statusCheckDisabled": "Disabled",
14892+
"@statusCheckDisabled": {
14893+
"description": "Status label on the service status page for a service the user has intentionally turned off (e.g. payjoin disabled in settings)."
1489014894
}
1489114895
}

0 commit comments

Comments
 (0)