File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
core/src/commonMain/kotlin/com/powersync/db Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 1.0.0-BETA22
4+ * Fix ` updateHasSynced ` internal null pointer exception
5+
36## 1.0.0-BETA21
47
58* Improve error handling for Swift by adding @Throws annotation so errors can be handled in Swift
Original file line number Diff line number Diff line change @@ -279,17 +279,24 @@ internal class PowerSyncDatabaseImpl(
279279 }
280280
281281 private suspend fun updateHasSynced () {
282- // Query the database to see if any data has been synced.
282+ data class SyncedAt (
283+ val syncedAt : String? ,
284+ )
285+ // Query the database to see if any data has been synced
283286 val timestamp =
284- internalDb.getOptional(" SELECT powersync_last_synced_at() as synced_at" , null ) { cursor ->
285- cursor.getString(0 ) ? : " "
287+ internalDb
288+ .getOptional(" SELECT powersync_last_synced_at() as synced_at" , null ) { cursor ->
289+ SyncedAt (syncedAt = cursor.getStringOptional(" synced_at" ))
290+ }?.syncedAt
291+ if (timestamp != null ) {
292+ val hasSynced = true
293+ if (currentStatus.hasSynced != null && hasSynced != currentStatus.hasSynced) {
294+ val formattedDateTime = " ${timestamp.replace(" " , " T" ).toLocalDateTime()} Z"
295+ val lastSyncedAt = Instant .parse(formattedDateTime)
296+ currentStatus.update(hasSynced = hasSynced, lastSyncedAt = lastSyncedAt)
286297 }
287-
288- val hasSynced = timestamp != " "
289- if (hasSynced != currentStatus.hasSynced) {
290- val formattedDateTime = " ${timestamp!! .replace(" " , " T" ).toLocalDateTime()} Z"
291- val lastSyncedAt = Instant .parse(formattedDateTime)
292- currentStatus.update(hasSynced = hasSynced, lastSyncedAt = lastSyncedAt)
298+ } else {
299+ currentStatus.update(hasSynced = false )
293300 }
294301 }
295302
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ development=true
1717RELEASE_SIGNING_ENABLED =true
1818# Library config
1919GROUP =com.powersync
20- LIBRARY_VERSION =1.0.0-BETA21
20+ LIBRARY_VERSION =1.0.0-BETA22
2121GITHUB_REPO =https://github.com/powersync-ja/powersync-kotlin.git
2222# POM
2323POM_URL =https://github.com/powersync-ja/powersync-kotlin/
You can’t perform that action at this time.
0 commit comments