Eduardo Ruesta
12/04/2024, 2:32 PMsuspend fun logout(): Flow<Any> {
return flow {
userDao.clearAll()
profileDao.clearAll()
qrCodeDao.clearAll()
teamDao.clearFavoriteCategory()
}
}
this is my Dao for QrCode:
@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 codeEduardo Ruesta
12/04/2024, 2:35 PM@Query("SELECT COUNT(*) FROM QRCode")
suspend fun getQrCodeCount(): Int
and in my repository im doing this:
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 PMblakelee
12/04/2024, 7:11 PMdb.useWriterConnection {
it.immediateTransaction {
// dao.clearAll()
}
}
Eduardo Ruesta
12/04/2024, 7:48 PM