mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-20 11:15:02 +01:00
only check for nc contacts if phonebook on device is not empty
This commit is contained in:
parent
5e1b69bbe6
commit
5b6fd3759f
@ -91,40 +91,38 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
// collect all contacts with phone number
|
// collect all contacts with phone number
|
||||||
val contactsWithNumbers = collectPhoneNumbers()
|
val contactsWithNumbers = collectPhoneNumbers()
|
||||||
|
|
||||||
val currentLocale = ConfigurationCompat.getLocales(context.resources.configuration)[0].country
|
if(contactsWithNumbers.isNotEmpty()){
|
||||||
|
val currentLocale = ConfigurationCompat.getLocales(context.resources.configuration)[0].country
|
||||||
|
|
||||||
val map = mutableMapOf<String, Any>()
|
val map = mutableMapOf<String, Any>()
|
||||||
map["location"] = currentLocale
|
map["location"] = currentLocale
|
||||||
map["search"] = contactsWithNumbers
|
map["search"] = contactsWithNumbers
|
||||||
|
|
||||||
val json = Gson().toJson(map)
|
val json = Gson().toJson(map)
|
||||||
|
|
||||||
ncApi.searchContactsByPhoneNumber(
|
ncApi.searchContactsByPhoneNumber(
|
||||||
ApiUtils.getCredentials(currentUser.username, currentUser.token),
|
ApiUtils.getCredentials(currentUser.username, currentUser.token),
|
||||||
ApiUtils.getUrlForSearchByNumber(currentUser.baseUrl),
|
ApiUtils.getUrlForSearchByNumber(currentUser.baseUrl),
|
||||||
RequestBody.create(MediaType.parse("application/json"), json))
|
RequestBody.create(MediaType.parse("application/json"), json))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : Observer<ContactsByNumberOverall> {
|
.subscribe(object : Observer<ContactsByNumberOverall> {
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(foundContacts: ContactsByNumberOverall) {
|
override fun onNext(foundContacts: ContactsByNumberOverall) {
|
||||||
Log.d(javaClass.simpleName, "next")
|
up(foundContacts)
|
||||||
|
}
|
||||||
|
|
||||||
// todo update
|
override fun onError(e: Throwable) {
|
||||||
up(foundContacts)
|
Log.e(javaClass.simpleName, "Failed to searchContactsByPhoneNumber", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
})
|
||||||
// TODO error handling
|
}
|
||||||
Log.d(javaClass.simpleName, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// store timestamp
|
// store timestamp
|
||||||
appPreferences.setPhoneBookIntegrationLastRun(System.currentTimeMillis())
|
appPreferences.setPhoneBookIntegrationLastRun(System.currentTimeMillis())
|
||||||
|
Loading…
Reference in New Issue
Block a user