This commit is contained in:
2026-06-29 19:43:04 +03:00
parent 00bdd63ea6
commit 19db4fe688
2 changed files with 6 additions and 6 deletions
@@ -13,9 +13,9 @@ class FeatureLimitException implements Exception {
class AccountRepository {
final AppDatabase _db;
final FeatureFlags _featureFlags;
final FeatureFlags Function() _getFeatureFlags;
AccountRepository(this._db, this._featureFlags);
AccountRepository(this._db, this._getFeatureFlags);
Stream<List<model.Account>> watchAll() {
return (_db.select(_db.accounts)
@@ -167,8 +167,9 @@ class AccountRepository {
Future<int> add(model.Account account) async {
final existing = await getAll();
final nonMainCount = existing.where((a) => !a.isMain).length;
if (nonMainCount >= _featureFlags.maxAccounts) {
throw FeatureLimitException('Account limit reached (${_featureFlags.maxAccounts})');
final flags = _getFeatureFlags();
if (flags.maxAccounts != -1 && nonMainCount >= flags.maxAccounts) {
throw FeatureLimitException('Account limit reached (${flags.maxAccounts})');
}
return await _db.into(_db.accounts).insert(
AccountsCompanion.insert(
+1 -2
View File
@@ -28,8 +28,7 @@ final transactionRepositoryProvider = Provider<TransactionRepository>((ref) {
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
final db = ref.watch(appDatabaseProvider);
final flags = ref.watch(featureFlagsProvider);
return AccountRepository(db, flags);
return AccountRepository(db, () => ref.read(featureFlagsProvider));
});
final storageServiceProvider = Provider<StorageService>((ref) {