Skip to content

Commit beca4be

Browse files
committed
fix: remove autoswap from announcements, home surface stays the warning card
1 parent 3954ce3 commit beca4be

6 files changed

Lines changed: 36 additions & 303 deletions

File tree

lib/features/announcements/announcements_locator.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import 'package:bb_mobile/core/storage/sqlite_database.dart';
2-
import 'package:bb_mobile/core/swaps/domain/usecases/get_auto_swap_settings_usecase.dart';
3-
import 'package:bb_mobile/core/swaps/domain/usecases/watch_auto_swap_settings_usecase.dart';
4-
import 'package:bb_mobile/core/wallet/domain/usecases/get_wallets_usecase.dart';
5-
import 'package:bb_mobile/core/wallet/domain/usecases/watch_finished_wallet_syncs_usecase.dart';
62
import 'package:bb_mobile/features/announcements/data/announcement_dismissal_repository_impl.dart';
73
import 'package:bb_mobile/features/announcements/data/datasources/announcement_dismissal_datasource.dart';
84
import 'package:bb_mobile/features/announcements/domain/usecases/dismiss_announcement_usecase.dart';
@@ -26,8 +22,6 @@ class AnnouncementsLocator {
2622
// Use-cases
2723
locator.registerFactory<GetVisibleAnnouncementsUsecase>(
2824
() => GetVisibleAnnouncementsUsecase(
29-
getWalletsUsecase: locator<GetWalletsUsecase>(),
30-
getAutoSwapSettingsUsecase: locator<GetAutoSwapSettingsUsecase>(),
3125
dismissalRepository: locator<AnnouncementDismissalRepository>(),
3226
),
3327
);
@@ -43,9 +37,6 @@ class AnnouncementsLocator {
4337
getVisibleAnnouncementsUsecase:
4438
locator<GetVisibleAnnouncementsUsecase>(),
4539
dismissAnnouncementUsecase: locator<DismissAnnouncementUsecase>(),
46-
watchFinishedWalletSyncsUsecase:
47-
locator<WatchFinishedWalletSyncsUsecase>(),
48-
watchAutoSwapSettingsUsecase: locator<WatchAutoSwapSettingsUsecase>(),
4940
),
5041
);
5142
}

lib/features/announcements/domain/entities/announcement_catalog.dart

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import 'package:bb_mobile/features/announcements/domain/entities/announcement.da
55
/// Extend this (and the gathering in `GetVisibleAnnouncementsUsecase`) as new
66
/// announcements need new signals.
77
class AnnouncementSignals {
8-
/// Whether autoswap is enabled AND the Liquid balance has actually reached
9-
/// its trigger threshold (`AutoSwap.passedRequiredBalance`) — the card
10-
/// informs about an imminent/behaving swap, so a balance that can't
11-
/// trigger one shouldn't surface it (product decision 2026-07-25).
12-
final bool isAutoswapTriggerable;
13-
14-
const AnnouncementSignals({required this.isAutoswapTriggerable});
8+
const AnnouncementSignals();
159
}
1610

1711
/// A catalog entry: an [Announcement] definition paired with the predicate that
@@ -37,21 +31,11 @@ class AnnouncementCatalogEntry {
3731
/// entry here with its trigger, and add the title/description l10n mapping in
3832
/// `presentation/announcement_l10n.dart`.
3933
///
40-
/// The payjoin-privacy nudge was removed on purpose (product decision
41-
/// 2026-07-25): payjoin education lives in the enable-time disclaimer and the
42-
/// payjoin settings screen, not on home. Its [AnnouncementId] value stays so
43-
/// persisted dismissals of it keep mapping cleanly.
44-
final List<AnnouncementCatalogEntry> announcementCatalog = [
45-
AnnouncementCatalogEntry(
46-
announcement: Announcement(
47-
id: AnnouncementId.autoswapActive,
48-
priority: 0,
49-
tone: AnnouncementTone.success,
50-
action: const NavigateAction(),
51-
dismissPolicy: const PermanentDismiss(),
52-
),
53-
// Show while autoswap is enabled AND the balance can actually trigger a
54-
// swap, letting the user learn what is about to happen to their funds.
55-
trigger: (s) => s.isAutoswapTriggerable,
56-
),
57-
];
34+
/// Currently EMPTY on purpose. The payjoin-privacy nudge was removed
35+
/// (product decision 2026-07-25): payjoin education lives in the enable-time
36+
/// disclaimer and the payjoin settings screen, not on home. The autoswap
37+
/// card was removed too (product decision 2026-07-28): autoswap's home
38+
/// surface is the pre-existing AutoSwapWarningCard driven by WalletBloc, as
39+
/// in the last release — not an announcement. Both [AnnouncementId] values
40+
/// stay so persisted dismissals keep mapping cleanly.
41+
final List<AnnouncementCatalogEntry> announcementCatalog = [];
Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,28 @@
1-
import 'package:bb_mobile/core/swaps/domain/usecases/get_auto_swap_settings_usecase.dart';
21
import 'package:bb_mobile/core/utils/result.dart';
3-
import 'package:bb_mobile/core/wallet/domain/usecases/get_wallets_usecase.dart';
42
import 'package:bb_mobile/features/announcements/domain/announcements_failure.dart';
53
import 'package:bb_mobile/features/announcements/domain/entities/announcement.dart';
64
import 'package:bb_mobile/features/announcements/domain/entities/announcement_catalog.dart';
75
import 'package:bb_mobile/features/announcements/domain/repositories/announcement_dismissal_repository.dart';
86

97
/// Orchestrates which announcements are currently visible on the home carousel.
108
///
11-
/// Thin orchestration only: it gathers the trigger signals (autoswap settings
12-
/// and the Liquid balance they apply to), asks each catalog entry whether its
13-
/// trigger fires, drops anything the user has dismissed (respecting the
14-
/// per-announcement dismiss policy), and returns the survivors ordered by
15-
/// ascending priority. All decision *rules* live on the entities / catalog;
16-
/// this use-case only wires signals to them.
9+
/// Thin orchestration only: it asks each catalog entry whether its trigger
10+
/// fires for the current [AnnouncementSignals], drops anything the user has
11+
/// dismissed (respecting the per-announcement dismiss policy), and returns
12+
/// the survivors ordered by ascending priority. All decision *rules* live on
13+
/// the entities / catalog; this use-case only wires signals to them. (The
14+
/// catalog is currently empty — see its doc comment — so this returns an
15+
/// empty list until a future announcement is added.)
1716
class GetVisibleAnnouncementsUsecase {
18-
final GetWalletsUsecase _getWalletsUsecase;
19-
final GetAutoSwapSettingsUsecase _getAutoSwapSettingsUsecase;
2017
final AnnouncementDismissalRepository _dismissalRepository;
2118

22-
GetVisibleAnnouncementsUsecase({
23-
required this._getWalletsUsecase,
24-
required this._getAutoSwapSettingsUsecase,
25-
required this._dismissalRepository,
26-
});
19+
GetVisibleAnnouncementsUsecase({required this._dismissalRepository});
2720

2821
Future<Result<List<Announcement>, AnnouncementsFailure>> execute() async {
2922
try {
30-
// The three sources are independent, so gather them concurrently.
31-
final (liquidBalanceSat, autoSwap, dismissals) = await (
32-
_defaultLiquidBalanceSat(),
33-
_getAutoSwapSettingsUsecase.execute(),
34-
_dismissalRepository.getDismissals(),
35-
).wait;
36-
37-
// Autoswap sweeps the default Liquid wallet, so its balance is what
38-
// the trigger threshold applies to. The threshold rule itself lives on
39-
// the AutoSwap entity (passedRequiredBalance also checks `enabled`).
40-
final signals = AnnouncementSignals(
41-
isAutoswapTriggerable:
42-
!autoSwap.showWarning &&
43-
autoSwap.passedRequiredBalance(liquidBalanceSat.toInt()),
44-
);
23+
final dismissals = await _dismissalRepository.getDismissals();
4524

25+
const signals = AnnouncementSignals();
4626
final dismissedAtById = {for (final d in dismissals) d.id: d.dismissedAt};
4727
final now = DateTime.now().toUtc();
4828

@@ -62,29 +42,7 @@ class GetVisibleAnnouncementsUsecase {
6242
visible.sort((a, b) => a.priority.compareTo(b.priority));
6343
return Ok(visible);
6444
} catch (e) {
65-
// Sources span wallets/autoswap/storage, so this is a genuine
66-
// catch-all rather than a storage-only failure.
6745
return Err(AnnouncementUnexpectedFailure(e.toString()));
6846
}
6947
}
70-
71-
/// Balance of the default Liquid wallet(s) of the current environment, or
72-
/// zero when there is none.
73-
///
74-
/// [GetWalletsUsecase] throws [NoWalletsFoundException] on an empty result,
75-
/// which would turn a perfectly ordinary state ("this environment has no
76-
/// default liquid wallet yet") into an `Err`, i.e. an error snackbar on the
77-
/// home screen, re-fired on every wallet sync. No wallet means no balance,
78-
/// which is a signal value, not a failure.
79-
Future<BigInt> _defaultLiquidBalanceSat() async {
80-
try {
81-
final wallets = await _getWalletsUsecase.execute(
82-
onlyLiquid: true,
83-
onlyDefaults: true,
84-
);
85-
return wallets.fold<BigInt>(BigInt.zero, (sum, w) => sum + w.balanceSat);
86-
} on NoWalletsFoundException {
87-
return BigInt.zero;
88-
}
89-
}
9048
}

lib/features/announcements/presentation/announcements_cubit.dart

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import 'dart:async';
2-
3-
import 'package:bb_mobile/core/wallet/domain/entities/wallet.dart';
4-
import 'package:bb_mobile/core/swaps/domain/entity/auto_swap.dart';
5-
import 'package:bb_mobile/core/swaps/domain/usecases/watch_auto_swap_settings_usecase.dart';
6-
import 'package:bb_mobile/core/wallet/domain/usecases/watch_finished_wallet_syncs_usecase.dart';
71
import 'package:bb_mobile/features/announcements/domain/announcements_failure.dart';
82
import 'package:bb_mobile/features/announcements/domain/usecases/dismiss_announcement_usecase.dart';
93
import 'package:bb_mobile/features/announcements/domain/entities/announcement.dart';
@@ -23,30 +17,19 @@ part 'announcements_state.dart';
2317
class AnnouncementsCubit extends Cubit<AnnouncementsState> {
2418
final GetVisibleAnnouncementsUsecase _getVisibleAnnouncementsUsecase;
2519
final DismissAnnouncementUsecase _dismissAnnouncementUsecase;
26-
final WatchFinishedWalletSyncsUsecase _watchFinishedWalletSyncsUsecase;
27-
final WatchAutoSwapSettingsUsecase _watchAutoSwapSettingsUsecase;
28-
29-
StreamSubscription<Wallet>? _walletSyncSub;
30-
StreamSubscription<AutoSwap>? _autoSwapSettingsSub;
3120

3221
bool _refreshing = false;
3322
bool _refreshQueued = false;
3423

24+
// No signal subscriptions: the catalog is currently empty, and its only
25+
// past signals (autoswap balance/settings) left with the autoswap card —
26+
// autoswap's home surface is AutoSwapWarningCard, not an announcement.
27+
// When a future announcement adds a signal, re-add the matching watch
28+
// here (see git history for the wallet-sync + autoswap-settings pair).
3529
AnnouncementsCubit({
3630
required this._getVisibleAnnouncementsUsecase,
3731
required this._dismissAnnouncementUsecase,
38-
required this._watchFinishedWalletSyncsUsecase,
39-
required this._watchAutoSwapSettingsUsecase,
40-
}) : super(const AnnouncementsState()) {
41-
// Re-evaluate after each wallet sync: the Liquid balance (the autoswap
42-
// trigger signal) only moves when a sync lands.
43-
_walletSyncSub = _watchFinishedWalletSyncsUsecase.execute().listen(
44-
(_) => refresh(),
45-
);
46-
_autoSwapSettingsSub = _watchAutoSwapSettingsUsecase.execute().listen(
47-
(_) => refresh(),
48-
);
49-
}
32+
}) : super(const AnnouncementsState());
5033

5134
/// (Re)loads the visible announcements. Called on mount and whenever a
5235
/// trigger signal changes.
@@ -86,11 +69,4 @@ class AnnouncementsCubit extends Cubit<AnnouncementsState> {
8669
(failure) async => emit(state.copyWith(failure: failure)),
8770
);
8871
}
89-
90-
@override
91-
Future<void> close() {
92-
_walletSyncSub?.cancel();
93-
_autoSwapSettingsSub?.cancel();
94-
return super.close();
95-
}
9672
}

0 commit comments

Comments
 (0)