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