Skip to content

Commit

Permalink
fix transaction reset (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgunozerk authored Dec 22, 2023
1 parent 00d4a7f commit 157e57a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/controllers/user_assets_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,22 @@ class UserAssetsController extends GetxController {
}

if (isThereAnyChange()) {
// applying category updates even when there are only transaction changes
// is not harmful, and `isThereAnyChange` check eliminates code duplication
// and extra checks for differentiating between category and transaction changes

_userAssets.value.pruneEmptyCategoriesOnSave();
_oldCategories = cloneCategoryMap(_userAssets.value.categoryMap);
_isThereAnyCategoryChange.value = false;
_transactions.value = Transactions.empty();
await _saveUserAssetsToDevice(_userAssets.value);
}
}

discardChanges() {
_userAssets.value.categoryMap = cloneCategoryMap(_oldCategories);
_isThereAnyCategoryChange.value = false;
_transactions.value = Transactions.empty();
_userAssets.value.assets = _snapshotsController.getLastSnapshot()!.clone();
}

Expand Down

0 comments on commit 157e57a

Please sign in to comment.