Skip to content

Commit 112a737

Browse files
committed
WIP - linter
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
1 parent 27fea57 commit 112a737

3 files changed

Lines changed: 43 additions & 52 deletions

File tree

app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,29 @@ class ContactsViewModel @Inject constructor(private val repository: ContactsRepo
119119
}
120120
}
121121

122-
suspend fun getBlockingContactsFromSearchParams(query: String = "") = withContext(Dispatchers.IO) {
123-
_contactsViewState.value = ContactsUiState.Loading
124-
try {
125-
val contacts = repository.getContacts(
126-
if (query != "") query else searchQuery.value,
127-
shareTypeList
128-
)
129-
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
130-
131-
if (hideAlreadyAddedParticipants && !_clickAddButton.value) {
132-
contactsList?.removeAll(selectedParticipants.value)
133-
}
134-
if (_clickAddButton.value) {
135-
contactsList?.removeAll(selectedParticipants.value)
136-
contactsList?.addAll(_selectedContacts.value)
122+
suspend fun getBlockingContactsFromSearchParams(query: String = "") =
123+
withContext(Dispatchers.IO) {
124+
_contactsViewState.value = ContactsUiState.Loading
125+
try {
126+
val contacts = repository.getContacts(
127+
if (query != "") query else searchQuery.value,
128+
shareTypeList
129+
)
130+
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
131+
132+
if (hideAlreadyAddedParticipants && !_clickAddButton.value) {
133+
contactsList?.removeAll(selectedParticipants.value)
134+
}
135+
if (_clickAddButton.value) {
136+
contactsList?.removeAll(selectedParticipants.value)
137+
contactsList?.addAll(_selectedContacts.value)
138+
}
139+
_contactsViewState.value = ContactsUiState.Success(contactsList)
140+
} catch (exception: Exception) {
141+
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
137142
}
138-
_contactsViewState.value = ContactsUiState.Success(contactsList)
139-
} catch (exception: Exception) {
140-
_contactsViewState.value = ContactsUiState.Error(exception.message ?: "")
141143
}
142144

143-
}
144-
145145
@Suppress("Detekt.TooGenericExceptionCaught")
146146
fun createRoom(roomType: String, sourceType: String?, userId: String, conversationName: String?) {
147147
viewModelScope.launch {

app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ class ConversationsListActivity :
483483

484484
searchableConversationItems.addAll(openConversationItems)
485485
}
486-
487486
}
488487
is ConversationsListViewModel.OpenConversationsUiState.Error -> {
489488
handleHttpExceptions(state.exception)
@@ -1560,18 +1559,6 @@ class ConversationsListActivity :
15601559
}
15611560
}
15621561

1563-
private suspend fun startBlockingMessageSearch(search: String?) = withContext(Dispatchers.IO) {
1564-
searchHelper?.startMessageSearch(search!!)
1565-
?.subscribeOn(Schedulers.io())
1566-
?.observeOn(AndroidSchedulers.mainThread())
1567-
?.blockingSubscribe({ results: MessageSearchResults -> onMessageSearchResult(results) }) { throwable:
1568-
Throwable ->
1569-
onMessageSearchError(
1570-
throwable
1571-
)
1572-
}
1573-
}
1574-
15751562
@SuppressLint("CheckResult") // handled by helper
15761563
private fun loadMoreMessages() {
15771564
binding.swipeRefreshLayoutView.isRefreshing = true

app/src/main/java/com/nextcloud/talk/conversationlist/viewmodels/ConversationsListViewModel.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -201,27 +201,31 @@ class ConversationsListViewModel @Inject constructor(
201201
}
202202
}
203203

204-
suspend fun fetchOpenConversations(searchTerm: String) = withContext(Dispatchers.IO) {
205-
_openConversationsState.value = OpenConversationsUiState.None
206-
207-
if (!hasSpreedFeatureCapability(currentUser.capabilities?.spreedCapability, SpreedFeatures.LISTABLE_ROOMS)) {
208-
return@withContext
209-
}
210-
211-
openConversationsRepository.fetchConversations(searchTerm)
212-
.onSuccess { conversations ->
213-
if (conversations.isEmpty()) {
214-
_openConversationsState.value = OpenConversationsUiState.None
215-
} else {
216-
_openConversationsState.value = OpenConversationsUiState.Success(conversations)
217-
}
218-
}
219-
.onFailure { exception ->
220-
Log.e(TAG, "Failed to fetch conversations", exception)
221-
_openConversationsState.value = OpenConversationsUiState.Error(exception)
204+
suspend fun fetchOpenConversations(searchTerm: String) =
205+
withContext(Dispatchers.IO) {
206+
_openConversationsState.value = OpenConversationsUiState.None
207+
208+
if (!hasSpreedFeatureCapability(
209+
currentUser.capabilities?.spreedCapability,
210+
SpreedFeatures.LISTABLE_ROOMS
211+
)
212+
) {
213+
return@withContext
222214
}
223215

224-
}
216+
openConversationsRepository.fetchConversations(searchTerm)
217+
.onSuccess { conversations ->
218+
if (conversations.isEmpty()) {
219+
_openConversationsState.value = OpenConversationsUiState.None
220+
} else {
221+
_openConversationsState.value = OpenConversationsUiState.Success(conversations)
222+
}
223+
}
224+
.onFailure { exception ->
225+
Log.e(TAG, "Failed to fetch conversations", exception)
226+
_openConversationsState.value = OpenConversationsUiState.Error(exception)
227+
}
228+
}
225229

226230
inner class FederatedInvitationsObserver : Observer<InvitationsModel> {
227231
override fun onSubscribe(d: Disposable) {

0 commit comments

Comments
 (0)