mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-23 11:39:15 +00:00
jtx-board-2-3-new-recur-handling (bitfireAT/davx5#196)
* adapted JtxSyncManager, added new method in LocalJtxCollection * minor code improvement * inserting recurring entry as well, as the series might not have been processed yet * version bump (preliminarily) * version bump (preliminarily)
This commit is contained in:
parent
4dd79606f2
commit
7b34f8148f
|
@ -17,8 +17,9 @@ android {
|
|||
defaultConfig {
|
||||
applicationId "at.bitfire.davdroid"
|
||||
|
||||
versionCode 403000005
|
||||
versionName '4.3'
|
||||
versionCode 403010000
|
||||
versionName '4.3.1-alpha.1'
|
||||
|
||||
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
|
||||
|
||||
setProperty "archivesBaseName", "davx5-ose-" + getVersionName()
|
||||
|
|
|
@ -78,6 +78,14 @@ class LocalJtxCollection(account: Account, client: ContentProviderClient, id: Lo
|
|||
return LocalJtxICalObject.Factory.fromProvider(this, values)
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and returns a recurring instance of a [LocalJtxICalObject]
|
||||
*/
|
||||
fun findRecurring(uid: String, recurid: String, dtstart: Long): LocalJtxICalObject? {
|
||||
val values = queryRecur(uid, recurid, dtstart) ?: return null
|
||||
return LocalJtxICalObject.Factory.fromProvider(this, values)
|
||||
}
|
||||
|
||||
override fun markNotDirty(flags: Int)= updateSetFlags(flags)
|
||||
|
||||
override fun removeNotDirtyMarked(flags: Int) = deleteByFlags(flags)
|
||||
|
|
|
@ -131,28 +131,44 @@ class JtxSyncManager(
|
|||
return
|
||||
}
|
||||
|
||||
if (icalobjects.size == 1) {
|
||||
val newData = icalobjects.first()
|
||||
Logger.log.log(Level.INFO, "Found ${icalobjects.size} entries in $fileName", icalobjects)
|
||||
|
||||
// update local task, if it exists
|
||||
localExceptionContext(localCollection.findByName(fileName)) { local ->
|
||||
if (local != null) {
|
||||
Logger.log.log(Level.INFO, "Updating $fileName in local task list", newData)
|
||||
local.eTag = eTag
|
||||
local.update(newData)
|
||||
syncResult.stats.numUpdates++
|
||||
} else {
|
||||
Logger.log.log(Level.INFO, "Adding $fileName to local task list", newData)
|
||||
|
||||
localExceptionContext(LocalJtxICalObject(localCollection, fileName, eTag, null, LocalResource.FLAG_REMOTELY_PRESENT)) {
|
||||
it.applyNewData(newData)
|
||||
it.add()
|
||||
icalobjects.forEach { jtxICalObject ->
|
||||
// if the entry is a recurring entry (and therefore has a recurid)
|
||||
// we udpate the existing (generated) entry
|
||||
if(jtxICalObject.recurid != null) {
|
||||
localExceptionContext(localCollection.findRecurring(jtxICalObject.uid, jtxICalObject.recurid!!, jtxICalObject.dtstart!!)) { local ->
|
||||
Logger.log.log(Level.INFO, "Updating $fileName with recur instance ${jtxICalObject.recurid} in local list", jtxICalObject)
|
||||
if(local != null) {
|
||||
local.update(jtxICalObject)
|
||||
syncResult.stats.numUpdates++
|
||||
} else {
|
||||
localExceptionContext(LocalJtxICalObject(localCollection, fileName, eTag, null, LocalResource.FLAG_REMOTELY_PRESENT)) {
|
||||
it.applyNewData(jtxICalObject)
|
||||
it.add()
|
||||
}
|
||||
syncResult.stats.numInserts++
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// otherwise we insert or update the main entry
|
||||
localExceptionContext(localCollection.findByName(fileName)) { local ->
|
||||
if (local != null) {
|
||||
Logger.log.log(Level.INFO, "Updating $fileName in local list", jtxICalObject)
|
||||
local.eTag = eTag
|
||||
local.update(jtxICalObject)
|
||||
syncResult.stats.numUpdates++
|
||||
} else {
|
||||
Logger.log.log(Level.INFO, "Adding $fileName to local list", jtxICalObject)
|
||||
|
||||
localExceptionContext(LocalJtxICalObject(localCollection, fileName, eTag, null, LocalResource.FLAG_REMOTELY_PRESENT)) {
|
||||
it.applyNewData(jtxICalObject)
|
||||
it.add()
|
||||
}
|
||||
syncResult.stats.numInserts++
|
||||
}
|
||||
syncResult.stats.numInserts++
|
||||
}
|
||||
}
|
||||
} else
|
||||
Logger.log.info("Received VCALENDAR with not exactly one VTODO or VJOURNAL; ignoring $fileName")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 1c6bcb3ffb0cef0b83ba59487c3ce9cfc10d262b
|
||||
Subproject commit 5d2df883803ecb9b9ca692df74bb880fbb12d36c
|
Loading…
Reference in a new issue