Skip to content

Commit

Permalink
NT-2180: Empty state showing when pull to refresh (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkariang committed Aug 16, 2021
1 parent dc99483 commit 6669919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -145,13 +145,14 @@ interface CommentsViewHolderViewModel {

init {

val comment = Observable.merge(this.commentInput.map { it.comment }, postedSuccessfully)
val comment = Observable.merge(this.commentInput.distinctUntilChanged().map { it.comment }, postedSuccessfully)
.filter { ObjectUtils.isNotNull(it) }
.map { requireNotNull(it) }

configureCommentCardWithComment(comment)

val commentCardStatus = this.commentInput
.distinctUntilChanged()
.filter { ObjectUtils.isNotNull(it) }
.map {
val commentCardState = cardStatus(it)
Expand All @@ -173,6 +174,7 @@ interface CommentsViewHolderViewModel {

this.internalError
.compose(combineLatestPair(commentData))
.distinctUntilChanged()
.compose(bindToLifecycle())
.delay(1, TimeUnit.SECONDS, environment.scheduler())
.subscribe {
Expand Down
Expand Up @@ -339,20 +339,17 @@ interface CommentsViewModel {
.loadWithParams {
loadWithProjectOrUpdateComments(Observable.just(it.first), it.second)
}
.clearWhenStartingOver(true)
.clearWhenStartingOver(false)
.build()

apolloPaginate.isFetching()
.compose(bindToLifecycle<Boolean>())
.subscribe(this.isFetchingComments)

apolloPaginate.paginatedData()
?.compose(combineLatestPair(this.isFetchingComments))
?.filter { !it.second }
?.distinctUntilChanged()
?.share()
?.subscribe {
this.commentsList.onNext(it.first)
this.commentsList.onNext(it)
}

this.internalError
Expand Down Expand Up @@ -421,7 +418,7 @@ interface CommentsViewModel {
.commentCardState(comment.cardStatus())
.commentableId(it.first.commentableId)
.build()
}
} ?: emptyList()

private fun buildCommentBody(it: Pair<User, Pair<String, DateTime>>): Comment {
return Comment.builder()
Expand Down

0 comments on commit 6669919

Please sign in to comment.