Daniel
04/05/2023, 4:12 PMrealm.syncSession.downloadAllServerChanges()
, which is a method from the Realm database that syncs data between the local Realm database and a remote server.
However, the data is not being downloaded real-time. I can see the data updated on mongo, but not on the app.
suspend fun verifyPaidStatus(id: String): Boolean
{
var out = false
while(!out)
{
realm.syncSession.downloadAllServerChanges()
realm.write {
val status =
realm.query<PaidStatus>("paidStatusId = $0", id).first().find()
if (status != null) {
findLatest(status)!!.also {
if(it.paidStatusId == id && it.message == "Approved") {
out = true
}
}
}
}
if(!out)
delay(1000)
}
return out
}
I call the method using:
val job = withTimeoutOrNull(10000)
{
verifyPaidStatus(invoiceId + restaurantMID)
}
if(job == null)
somethingWrong = true
How is this possible?