From a4ec8b914e9619640047ed9225d4b574ea1e4aea Mon Sep 17 00:00:00 2001 From: soraefir Date: Fri, 4 Sep 2026 02:52:56 +0200 Subject: [PATCH] Sync improvements --- .../cowspent/persistence/CowspentServerSyncHelper.kt | 10 ++++++---- .../java/net/helcel/cowspent/util/NextcloudClient.kt | 8 ++++---- .../helcel/cowspent/util/VersatileProjectSyncClient.kt | 5 ++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/net/helcel/cowspent/persistence/CowspentServerSyncHelper.kt b/app/src/main/java/net/helcel/cowspent/persistence/CowspentServerSyncHelper.kt index d42235e..f0a8460 100644 --- a/app/src/main/java/net/helcel/cowspent/persistence/CowspentServerSyncHelper.kt +++ b/app/src/main/java/net/helcel/cowspent/persistence/CowspentServerSyncHelper.kt @@ -1029,12 +1029,14 @@ class CowspentServerSyncHelper private constructor(private val dbHelper: Cowspen var status = LoginStatus.OK try { // Pass current project values if the new ones are null to ensure a complete project object is sent to the server + val currentProj = project!! + val finalName = (newName ?: currentProj.name).let { if (it.isBlank() || it == "null") currentProj.remoteId else it } val response = client!!.editRemoteProject( - project!!, - newName ?: project.name, - newEmail ?: project.email, + currentProj, + finalName, + newEmail ?: currentProj.email, newPassword, - newMainCurrencyName ?: project.currencyName, + newMainCurrencyName ?: currentProj.currencyName, newArchivedTs ) if (BillsListViewActivity.DEBUG) { diff --git a/app/src/main/java/net/helcel/cowspent/util/NextcloudClient.kt b/app/src/main/java/net/helcel/cowspent/util/NextcloudClient.kt index 5d0e244..59e0f4d 100644 --- a/app/src/main/java/net/helcel/cowspent/util/NextcloudClient.kt +++ b/app/src/main/java/net/helcel/cowspent/util/NextcloudClient.kt @@ -86,7 +86,7 @@ class NextcloudClient( } @Throws(TokenMismatchException::class, NextcloudHttpRequestFailedException::class) - private fun requestServerWithSSO( + internal fun requestServerWithSSO( nextcloudAPI: NextcloudAPI, target: String, method: String, @@ -141,7 +141,7 @@ class NextcloudClient( } @Throws(TokenMismatchException::class, NextcloudHttpRequestFailedException::class) - private fun imageRequestServerWithSSO( + internal fun imageRequestServerWithSSO( nextcloudAPI: NextcloudAPI, target: String, method: String, @@ -182,7 +182,7 @@ class NextcloudClient( } @Throws(IOException::class, NextcloudHttpRequestFailedException::class) - private fun requestServer( + internal fun requestServer( target: String, method: String, params: JSONObject?, lastETag: String?, needLogin: Boolean, isOCSRequest: Boolean ): VersatileProjectSyncClient.ResponseData { @@ -248,7 +248,7 @@ class NextcloudClient( } @Throws(IOException::class, NextcloudHttpRequestFailedException::class) - private fun imageRequestServer( + internal fun imageRequestServer( target: String, method: String, params: JSONObject?, lastETag: String?, needLogin: Boolean, isOCSRequest: Boolean ): VersatileProjectSyncClient.ResponseData { diff --git a/app/src/main/java/net/helcel/cowspent/util/VersatileProjectSyncClient.kt b/app/src/main/java/net/helcel/cowspent/util/VersatileProjectSyncClient.kt index fff592e..193a805 100644 --- a/app/src/main/java/net/helcel/cowspent/util/VersatileProjectSyncClient.kt +++ b/app/src/main/java/net/helcel/cowspent/util/VersatileProjectSyncClient.kt @@ -163,11 +163,10 @@ class VersatileProjectSyncClient( paramValues.add(newEmail) } if (newMainCurrencyName != null) { - paramKeys.add("currencyname") - paramValues.add(newMainCurrencyName) + paramKeys.add("currencyName") } if (newArchivedTs != null) { - paramKeys.add("archived_ts") + paramKeys.add("archivedTs") paramValues.add(newArchivedTs.toString()) } }