Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit ce458e09 authored by Patrick Lang's avatar Patrick Lang Committed by GitHub
Browse files

Updated queryByUID to query independent of current collection (#37)

parent 82c12e14
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -132,11 +132,12 @@ open class JtxCollection<out T: JtxICalObject>(val account: Account,
    }

    /**
     * @param [UID] of the entry that should be retrieved as content values
     * @param [uid] of the entry that should be retrieved as content values
     * @return Content Values of the found item with the given UID or null if the result was empty or more than 1
     * The query checks for the [uid] within all collections of this account, not only the current collection.
     */
    fun queryByUID(uid: String): ContentValues? {
        client.query(JtxContract.JtxICalObject.CONTENT_URI.asSyncAdapter(account), null, "${JtxContract.JtxICalObject.ICALOBJECT_COLLECTIONID} = ? AND ${JtxContract.JtxICalObject.UID} = ?", arrayOf(id.toString(), uid), null).use { cursor ->
        client.query(JtxContract.JtxICalObject.CONTENT_URI.asSyncAdapter(account), null, "${JtxContract.JtxICalObject.UID} = ?", arrayOf(uid), null).use { cursor ->
            Ical4Android.log.fine("queryByUID: found ${cursor?.count} records in ${account.name}")
            if (cursor?.count != 1)
                return null