1
0
mirror of https://github.com/etesync/android synced 2025-01-23 06:01:01 +00:00

Sync notifications: fix changes notifications to not show for items we pushed.

This commit is contained in:
Tom Hacohen 2020-09-10 18:09:07 +03:00
parent 16f7187a77
commit 2b88ad6896

View File

@ -381,7 +381,18 @@ constructor(protected val context: Context, protected val account: Account, prot
private fun persistItem(item: Item) { private fun persistItem(item: Item) {
synchronized(etebaseLocalCache) { synchronized(etebaseLocalCache) {
etebaseLocalCache.itemSet(itemMgr, cachedCollection.col.uid, item) // FIXME: it's terrible that we are fetching and decrypting the item here - we really don't have to
val cached = etebaseLocalCache.itemGet(itemMgr, cachedCollection.col.uid, item.uid)
if (cached?.item?.etag != item.etag) {
syncItemsTotal++
if (item.isDeleted) {
syncItemsDeleted++
} else {
syncItemsChanged++
}
etebaseLocalCache.itemSet(itemMgr, cachedCollection.col.uid, item)
}
} }
} }
@ -415,6 +426,12 @@ constructor(protected val context: Context, protected val account: Account, prot
throw e throw e
} }
} }
when (syncEntry.action) {
ADD -> syncItemsChanged++
SyncEntry.Actions.DELETE -> syncItemsDeleted++
SyncEntry.Actions.CHANGE -> syncItemsChanged++
}
} }
@Throws(IOException::class, CalendarStorageException::class, ContactsStorageException::class) @Throws(IOException::class, CalendarStorageException::class, ContactsStorageException::class)
@ -442,7 +459,6 @@ constructor(protected val context: Context, protected val account: Account, prot
// Process new vcards from server // Process new vcards from server
val size = items.size val size = items.size
var i = 0 var i = 0
syncItemsTotal += size
for (item in items) { for (item in items) {
if (Thread.interrupted()) { if (Thread.interrupted()) {
@ -451,12 +467,6 @@ constructor(protected val context: Context, protected val account: Account, prot
i++ i++
Logger.log.info("Processing (${i}/${size}) UID=${item.uid} Etag=${item.etag}") Logger.log.info("Processing (${i}/${size}) UID=${item.uid} Etag=${item.etag}")
if (item.isDeleted) {
syncItemsDeleted++
} else {
syncItemsChanged++
}
processItem(item) processItem(item)
persistItem(item) persistItem(item)
} }
@ -516,13 +526,6 @@ constructor(protected val context: Context, protected val account: Account, prot
error = e.toString() error = e.toString()
} }
val action = cEntry.action
when (action) {
ADD -> syncItemsChanged++
SyncEntry.Actions.DELETE -> syncItemsDeleted++
SyncEntry.Actions.CHANGE -> syncItemsChanged++
}
persistSyncEntry(entry.uid, cEntry, error) persistSyncEntry(entry.uid, cEntry, error)
remoteCTag = entry.uid remoteCTag = entry.uid