File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
app/src/main/java/com/example/tamaskozmer/kotlinrxexample/model Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -32,15 +32,19 @@ class UserRepository(
32
32
}
33
33
34
34
private fun mapAnswersToAnswerViewModels (answers : List <Answer >): Single <List <AnswerViewModel >> {
35
- val ids = answers
35
+ val processedAnswers = answers
36
+ .filter { it.accepted }
37
+ .take(3 )
38
+
39
+ val ids = processedAnswers
36
40
.map { it.questionId.toString() }
37
41
.joinToString(separator = " ;" )
38
42
39
43
val questionsListModel = questionService.getQuestionById(ids)
40
44
41
45
return questionsListModel
42
46
.map { questionListModel: QuestionListModel ? ->
43
- addTitlesToAnswers(answers , questionListModel?.items ? : emptyList()) }
47
+ addTitlesToAnswers(processedAnswers , questionListModel?.items ? : emptyList()) }
44
48
}
45
49
46
50
private fun addTitlesToAnswers (answers : List <Answer >, questions : List <Question >) : List <AnswerViewModel > {
@@ -58,10 +62,6 @@ class UserRepository(
58
62
val favorites = favoritesModel.items
59
63
.take(3 )
60
64
61
- val answers = answersModel
62
- .filter { it.accepted }
63
- .take(3 )
64
-
65
- return DetailsModel (questions, answers, favorites)
65
+ return DetailsModel (questions, answersModel, favorites)
66
66
}
67
67
}
You can’t perform that action at this time.
0 commit comments