Sync improvements
This commit is contained in:
@@ -754,7 +754,7 @@ class BillsListViewActivity :
|
||||
}
|
||||
|
||||
if (db.cowspentServerSyncHelper.isSyncPossible) {
|
||||
viewModel.isRefreshing = manual
|
||||
viewModel.isRefreshing = true
|
||||
val selectedProjectId = preferences.getLong("selected_project", 0)
|
||||
|
||||
lifecycleScope.launch {
|
||||
@@ -771,10 +771,9 @@ class BillsListViewActivity :
|
||||
viewModel.isRefreshing = false
|
||||
}
|
||||
|
||||
// Sync other projects (they will be queued)
|
||||
remoteProjects.filter { it.id != selectedProjectId }.forEach {
|
||||
db.cowspentServerSyncHelper.scheduleSync(false, it.id, manual)
|
||||
}
|
||||
// remoteProjects.filter { it.id != selectedProjectId }.forEach {
|
||||
// db.cowspentServerSyncHelper.scheduleSync(false, it.id, manual)
|
||||
// }
|
||||
} else {
|
||||
viewModel.isRefreshing = false
|
||||
}
|
||||
|
||||
@@ -1244,17 +1244,18 @@ class CowspentSQLiteOpenHelper private constructor(val context: Context) :
|
||||
@Volatile
|
||||
private var instance: CowspentSQLiteOpenHelper? = null
|
||||
|
||||
@VisibleForTesting
|
||||
var overrideInstance: CowspentSQLiteOpenHelper? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(context: Context): CowspentSQLiteOpenHelper {
|
||||
overrideInstance?.let { return it }
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: CowspentSQLiteOpenHelper(context.applicationContext).also { instance = it }
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun setInstance(helper: CowspentSQLiteOpenHelper?) {
|
||||
instance = helper
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun resetInstance() {
|
||||
instance = null
|
||||
|
||||
@@ -1028,8 +1028,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 response = client!!.editRemoteProject(
|
||||
project!!, newName, newEmail, newPassword, newMainCurrencyName, newArchivedTs
|
||||
project!!,
|
||||
newName ?: project.name,
|
||||
newEmail ?: project.email,
|
||||
newPassword,
|
||||
newMainCurrencyName ?: project.currencyName,
|
||||
newArchivedTs
|
||||
)
|
||||
if (BillsListViewActivity.DEBUG) {
|
||||
Log.i(TAG, "RESPONSE edit remote project : ${response.stringContent}")
|
||||
|
||||
@@ -163,7 +163,7 @@ class VersatileProjectSyncClient(
|
||||
paramValues.add(newEmail)
|
||||
}
|
||||
if (newMainCurrencyName != null) {
|
||||
paramKeys.add("currencyName")
|
||||
paramKeys.add("currencyname")
|
||||
paramValues.add(newMainCurrencyName)
|
||||
}
|
||||
if (newArchivedTs != null) {
|
||||
|
||||
Reference in New Issue
Block a user