Hello all, VerifyPaidStatus is used verify the pa...
# multiplatform
d
Hello all, VerifyPaidStatus is used verify the payment status of a user identified by their id. The function is using a while loop to continuously check the payment status until it is approved. Within the loop, the function is downloading all server changes using
realm.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.
Copy code
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:
Copy code
val job = withTimeoutOrNull(10000)
 {
     verifyPaidStatus(invoiceId + restaurantMID)
 }

 if(job == null)
    somethingWrong = true
How is this possible?