Skip to content

Commit

Permalink
chore: 🔥 Remove contact management
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Dec 28, 2024
1 parent 68431fb commit 05997d7
Show file tree
Hide file tree
Showing 41 changed files with 547 additions and 1,193 deletions.
28 changes: 28 additions & 0 deletions lib/application/account/accounts.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later
import 'dart:async';

import 'package:aewallet/application/account/accounts_notifier.dart';
import 'package:aewallet/model/data/account.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'accounts.g.dart';

@riverpod
Future<Account?> accountWithGenesisAddress(
Ref ref,
String genesisAddress,
) async {
final accounts = await ref.watch(accountsNotifierProvider.future);
return accounts.getAccountWithGenesisAddress(genesisAddress);
}

@riverpod
Future<Account?> accountWithName(
Ref ref,
String nameAccount,
) async {
final accounts = await ref.watch(accountsNotifierProvider.future);
return accounts.getAccountWithName(nameAccount);
}
295 changes: 295 additions & 0 deletions lib/application/account/accounts.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions lib/application/account/accounts_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:aewallet/application/session/session.dart';
import 'package:aewallet/infrastructure/datasources/account.hive.dart';
import 'package:aewallet/infrastructure/repositories/local_account.dart';
import 'package:aewallet/model/data/account.dart';
import 'package:collection/collection.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'accounts_notifier.g.dart';
Expand Down Expand Up @@ -69,6 +70,24 @@ extension AccountsExt on List<Account> {
}
return null;
}

Account? getAccountWithGenesisAddress(
String genesisAddress,
) {
return firstWhereOrNull(
(account) =>
account.genesisAddress.toLowerCase() == genesisAddress.toLowerCase(),
);
}

Account? getAccountWithName(
String nameAccount,
) {
return firstWhereOrNull(
(account) =>
account.nameDisplayed.toLowerCase() == nameAccount.toLowerCase(),
);
}
}

extension FutureAccountsExt on Future<List<Account>> {
Expand Down
Loading

0 comments on commit 05997d7

Please sign in to comment.