diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/ConfigDatabase.kt b/app/src/main/java/org/thoughtcrime/securesms/database/ConfigDatabase.kt index 5006da99f7..d4c455308c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ConfigDatabase.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ConfigDatabase.kt @@ -102,10 +102,14 @@ class ConfigDatabase(context: Context, helper: SQLCipherOpenHelper): Database(co } fun retrieveConfigLastUpdateTimestamp(variant: ConfigVariant, publicKey: String): Long { - val db = readableDatabase - val cursor = db.query(TABLE_NAME, arrayOf(TIMESTAMP), VARIANT_AND_PUBKEY_WHERE, arrayOf(variant, publicKey),null, null, null) - if (cursor == null) return 0 - if (!cursor.moveToFirst()) return 0 - return (cursor.getLongOrNull(cursor.getColumnIndex(TIMESTAMP)) ?: 0) + return readableDatabase + .query(TABLE_NAME, arrayOf(TIMESTAMP), VARIANT_AND_PUBKEY_WHERE, arrayOf(variant, publicKey), null, null, null) + ?.use { cursor -> + if (cursor.moveToFirst()) { + cursor.getLongOrNull(cursor.getColumnIndex(TIMESTAMP)) + } else { + null + } + } ?: 0L } } \ No newline at end of file