Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.0.0-BETA22
* Fix `updateHasSynced` internal null pointer exception

## 1.0.0-BETA21

* Improve error handling for Swift by adding @Throws annotation so errors can be handled in Swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,18 @@ internal class PowerSyncDatabaseImpl(
}

private suspend fun updateHasSynced() {
// Query the database to see if any data has been synced.
data class SyncedAt(
val syncedAt: String?,
)
// Query the database to see if any data has been synced
val timestamp =
internalDb.getOptional("SELECT powersync_last_synced_at() as synced_at", null) { cursor ->
cursor.getString(0) ?: ""
}

val hasSynced = timestamp != ""
if (hasSynced != currentStatus.hasSynced) {
val formattedDateTime = "${timestamp!!.replace(" ", "T").toLocalDateTime()}Z"
internalDb
.getOptional("SELECT powersync_last_synced_at() as synced_at", null) { cursor ->
SyncedAt(syncedAt = cursor.getStringOptional("synced_at"))
}?.syncedAt
val hasSynced = timestamp != null
if (currentStatus.hasSynced != null && hasSynced != currentStatus.hasSynced) {
val formattedDateTime = "${timestamp!!.replace(" ","T").toLocalDateTime()}Z"
val lastSyncedAt = Instant.parse(formattedDateTime)
currentStatus.update(hasSynced = hasSynced, lastSyncedAt = lastSyncedAt)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ development=true
RELEASE_SIGNING_ENABLED=true
# Library config
GROUP=com.powersync
LIBRARY_VERSION=1.0.0-BETA21
LIBRARY_VERSION=1.0.0-BETA22
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
# POM
POM_URL=https://github.com/powersync-ja/powersync-kotlin/
Expand Down