]> git.ktnx.net Git - mobile-ledger.git/commitdiff
store transaction list in a db transaction
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 24 Apr 2021 18:29:16 +0000 (18:29 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 25 Apr 2021 17:07:58 +0000 (17:07 +0000)
otherwise each insert/update triggers a re-fetch of the while list,
which is devastating for the UI and the battery

app/src/main/java/net/ktnx/mobileledger/dao/TransactionDAO.java

index 2c0995e1226cef8480babebff7ac8f3623008721..715d6ea1d72272e9c6ba736697432e8ba4cd3794 100644 (file)
@@ -161,6 +161,7 @@ public abstract class TransactionDAO extends BaseDAO<Transaction> {
             return 0;
         return result.generation;
     }
+    @androidx.room.Transaction
     public void storeTransactionsSync(List<TransactionWithAccounts> list, long profileId) {
         long generation = getGenerationSync(profileId) + 1;
 
@@ -179,7 +180,8 @@ public abstract class TransactionDAO extends BaseDAO<Transaction> {
         Logger.debug("Transaction",
                 String.format(Locale.ROOT, "Purged %d transaction accounts", removed));
     }
-    private void storeSync(TransactionWithAccounts rec) {
+    @androidx.room.Transaction
+    void storeSync(TransactionWithAccounts rec) {
         TransactionAccountDAO trAccDao = DB.get()
                                            .getTransactionAccountDAO();