Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
5020a67d
Unverified
Commit
5020a67d
authored
Jan 28, 2019
by
Allan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary try catch
parent
5fab419e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
18 deletions
+13
-18
ChatRoomsViewModel.kt
.../rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
+13
-18
No files found.
app/src/main/java/chat/rocket/android/chatrooms/viewmodel/ChatRoomsViewModel.kt
View file @
5020a67d
...
...
@@ -23,7 +23,6 @@ import com.shopify.livedataktx.nonNull
import
kotlinx.coroutines.experimental.*
import
kotlinx.coroutines.experimental.android.UI
import
timber.log.Timber
import
java.lang.IllegalArgumentException
class
ChatRoomsViewModel
(
private
val
connectionManager
:
ConnectionManager
,
...
...
@@ -43,23 +42,19 @@ class ChatRoomsViewModel(
return
@switchMap
if
(
query
.
isSearch
())
{
this
@ChatRoomsViewModel
.
query
.
wrap
(
runContext
)
{
_
,
data
:
MutableLiveData
<
RoomsModel
>
->
try
{
val
string
=
(
query
as
Query
.
Search
).
query
// debounce, to not query while the user is writing
delay
(
200
)
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
data
.
postValue
(
rooms
.
toMutableList
()
+
LoadingItemHolder
())
yield
()
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
yield
()
spotlight
?.
let
{
data
.
postValue
(
rooms
.
toMutableList
()
+
spotlight
)
}.
ifNull
{
data
.
postValue
(
rooms
)
}
}
catch
(
ignore
:
CancellationException
)
{
val
string
=
(
query
as
Query
.
Search
).
query
// debounce, to not query while the user is writing
delay
(
200
)
val
rooms
=
repository
.
search
(
string
).
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
data
.
postValue
(
rooms
.
toMutableList
()
+
LoadingItemHolder
())
yield
()
val
spotlight
=
spotlight
(
query
.
query
)
?.
let
{
mapper
.
map
(
it
,
showLastMessage
=
this
.
showLastMessage
)
}
yield
()
spotlight
?.
let
{
data
.
postValue
(
rooms
.
toMutableList
()
+
spotlight
)
}.
ifNull
{
data
.
postValue
(
rooms
)
}
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment