@Query("DELETE FROM QRCode")
suspend fun clearAll()
when the user clicks on logout and then login again in the same session (without killing the app) and goes to the Qr code screen will see again the old Qr code
Eduardo Ruesta
12/04/2024, 2:35 PM
i have this method to check if there is something in the Qr database:
Copy code
@Query("SELECT COUNT(*) FROM QRCode")
suspend fun getQrCodeCount(): Int
and in my repository im doing this:
Copy code
val qrCodeCount = qrCodeDao.getQrCodeCount()
if (qrCodeCount > 0) {
val qrCode = qrCodeDao.fetchQrCode().firstOrNull()
emit(qrCode)
} else {
val newQRCode = personService.getQRCode(
personId,
BuildConfig.X_Api_Key,
BuildConfig.X_Api_ClientKey
)
qrCodeDao.save(newQRCode)
emit(newQRCode)
}
Eduardo Ruesta
12/04/2024, 2:36 PM
so the issue is that if the user logout and login in the same session will see the old qr. If the user kill the app the issue is not happened since the database was refreshing
b
blakelee
12/04/2024, 7:11 PM
Assuming the table name is correct, maybe you could trying to do all of the clears in a transaction