Skip to content

Commit

Permalink
Fixing items added to a group sometimes not getting synced until an a…
Browse files Browse the repository at this point in the history
…pp restart.

Doing a realm.refresh() to sync Realm Instances after certain database operations.

Upping versionCode to 77
  • Loading branch information
Dima-Android committed Jun 20, 2024
1 parent ca9e8bc commit 5510710
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 21 deletions.
11 changes: 3 additions & 8 deletions app/src/main/java/org/zotero/android/database/RealmDbStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RealmDbStorage(val config: RealmConfiguration) {
val result = coordinator.perform(request = request)

if (invalidateRealm) {
coordinator.invalidate()
coordinator.refresh()
}

return result
Expand All @@ -59,13 +59,13 @@ class RealmDbStorage(val config: RealmConfiguration) {
fun perform(request: DbRequest) {
val coordinator = RealmDbCoordinator().init(config)
coordinator.perform(request = request)
coordinator.invalidate()
coordinator.refresh()
}

fun perform(requests: List<DbRequest>) {
val coordinator = RealmDbCoordinator().init(config)
coordinator.perform(requests)
coordinator.invalidate()
coordinator.refresh()
}
}

Expand Down Expand Up @@ -138,9 +138,4 @@ class RealmDbCoordinator {
realm.refresh()
}

fun invalidate() {
// realm.invalidate()
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ internal class FilterViewModel @Inject constructor(
// }
}

coordinator.invalidate()
coordinator.refresh()
if (!viewState.searchTerm.isEmpty()) {
// Perform search filter if needed
snapshot = sorted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ShareItemSubmitter @Inject constructor(
parameters = item.updateParameters?.toMutableMap() ?: mutableMapOf()
changeUuids = mutableMapOf(item.key to item.changes.map { it.identifier })

coordinator.invalidate()
coordinator.refresh()
}

return parameters to changeUuids
Expand Down Expand Up @@ -118,7 +118,7 @@ class ShareItemSubmitter @Inject constructor(
.findFirst()?.value?.toLongOrNull()
md5 = attachment.fields.where().key(FieldKeys.Item.Attachment.md5).findFirst()?.value

coordinator.invalidate()
coordinator.refresh()
}
if (mtime == null) {
throw AttachmentState.Error.mtimeMissing
Expand Down Expand Up @@ -172,7 +172,7 @@ class ShareItemSubmitter @Inject constructor(
.findFirst()?.value?.toLongOrNull()
md5 = attachment.fields.where().key(FieldKeys.Item.Attachment.md5).findFirst()?.value

coordinator.invalidate()
coordinator.refresh()
}

mtime ?: throw AttachmentState.Error.mtimeMissing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AttachmentFileCleanupController @Inject constructor(
}

coordinator.perform(request = MarkAllFilesAsNotDownloadedDbRequest())
coordinator.invalidate()
coordinator.refresh()
}

val deletedIndividually = delete(libraryIds, forUpload = forUpload)
Expand Down Expand Up @@ -203,7 +203,7 @@ class AttachmentFileCleanupController @Inject constructor(
)
)

coordinator.invalidate()
coordinator.refresh()
}

for (key in toDelete) {
Expand Down Expand Up @@ -246,7 +246,7 @@ class AttachmentFileCleanupController @Inject constructor(
downloaded = false
)
)
coordinator.invalidate()
coordinator.refresh()
canDelete = true
}
if (canDelete) {
Expand All @@ -270,7 +270,7 @@ class AttachmentFileCleanupController @Inject constructor(

coordinator.perform(request = MarkLibraryFilesAsNotDownloadedDbRequest(libraryId = libraryId))

coordinator.invalidate()
coordinator.refresh()
}

val deletedIndividually =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RevertLibraryFilesSyncAction(
)
changedFilenames =
coordinator.perform(request = request).changedFilenames.toMutableList()
coordinator.invalidate()
coordinator.refresh()
}

Timber.e("RevertLibraryFilesSyncAction: rename local files to match file names")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class RevertLibraryUpdatesSyncAction(
failedCollections = collections.second.toMutableList()
failedSearches = searches.second.toMutableList()
failedItems = items.second.toMutableList()
coordinator.invalidate()
coordinator.refresh()
}

renameExistingFiles(changes = changes, libraryId = this.libraryId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SubmitDeletionSyncAction(
}
}
coordinator.perform(requests)
coordinator.invalidate()
coordinator.refresh()
}
return didCreateDeletions
} catch (error: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class SyncVersionsSyncAction(
)
identifiers = coordinator.perform(request = request).toMutableList()

coordinator.invalidate()
coordinator.refresh()
})
return Pair(newVersion, identifiers)
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 76 // Must be updated on every build
val versionCode = 77 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit 5510710

Please sign in to comment.