Skip to content

Commit

Permalink
IMPORT - remove internal wallets before /home
Browse files Browse the repository at this point in the history
  • Loading branch information
mocodesmo committed Dec 26, 2024
1 parent abe2efb commit 8ea045b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796

COCOAPODS: 1.16.2
COCOAPODS: 1.15.2
9 changes: 9 additions & 0 deletions lib/import/wallet_type_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:bb_mobile/import/bloc/import_state.dart';
import 'package:bb_mobile/locator.dart';
import 'package:bb_mobile/network/bloc/network_cubit.dart';
import 'package:bb_mobile/styles.dart';
import 'package:bb_mobile/wallet/bloc/event.dart';
import 'package:bb_mobile/wallet/bloc/wallet_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
Expand Down Expand Up @@ -57,6 +58,9 @@ class ImportSelectWalletTypeScreen extends StatelessWidget {
listener: (context, state) async {
if (!state.savedWallet) return;
//if (state.mainWallet)
for (final w in walletCubits) {
w.add(RemoveInternalWallet());
}
await locator<WalletsStorageRepository>().sortWallets();
locator<HomeCubit>().getWalletsFromStorage();
// final wallet = state.savedWallet!;
Expand Down Expand Up @@ -91,6 +95,11 @@ class _ScreenState extends State<_Screen> {
}
}

@override
void dispose() {
super.dispose();
}

@override
Widget build(BuildContext context) {
final saving =
Expand Down
2 changes: 2 additions & 0 deletions lib/wallet/bloc/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SyncWallet extends WalletEvent {
final bool cancelSync;
}

class RemoveInternalWallet extends WalletEvent {}

class KillSync extends WalletEvent {}

class UpdateWallet extends WalletEvent {
Expand Down
9 changes: 9 additions & 0 deletions lib/wallet/bloc/wallet_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ class WalletBloc extends Bloc<WalletEvent, WalletState> {
super(WalletState(wallet: wallet)) {
on<LoadWallet>(_loadWallet);
on<SyncWallet>(_syncWallet, transformer: droppable());
on<RemoveInternalWallet>(_removeInternalWallet);
on<KillSync>(_killSync);
on<UpdateWallet>(_updateWallet, transformer: sequential());
on<GetBalance>(_getBalance);
on<ListTransactions>(_listTransactions);
on<GetFirstAddress>(_getFirstAddress);

add(LoadWallet(saveDir));
}

Expand Down Expand Up @@ -119,6 +121,13 @@ class WalletBloc extends Bloc<WalletEvent, WalletState> {
add(SyncWallet());
}

FutureOr<void> _removeInternalWallet(
RemoveInternalWallet event,
Emitter<WalletState> emit,
) {
_walletsRepository.removeBdkWallet(state.wallet?.id ?? '');
}

FutureOr<void> _killSync(KillSync event, Emitter<WalletState> emit) {
_walletSync.cancelSync();
emit(state.copyWith(syncing: false));
Expand Down
10 changes: 5 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ packages:
description:
path: "."
ref: trunk
resolved-ref: "81b2b02fb95aa7df92c7d1c2dd2772c5d48e172e"
resolved-ref: "79247f0e87dd90ec95c088649b9db3bbf9e10acd"
url: "https://github.com/SatoshiPortal/lwk-dart.git"
source: git
version: "0.1.5"
Expand Down Expand Up @@ -1139,10 +1139,10 @@ packages:
dependency: transitive
description:
name: pubspec_parse
sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8
sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
qr:
dependency: transitive
description:
Expand Down Expand Up @@ -1544,10 +1544,10 @@ packages:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.3"
sdks:
dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.0"

0 comments on commit 8ea045b

Please sign in to comment.