Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: redundant code after zip #2044

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class EventDetailsViewModel(
val eventSponsors: LiveData<List<Sponsor>> = mutableEventSponsors
private val mutableSocialLinks = MutableLiveData<List<SocialLink>>()
val socialLinks: LiveData<List<SocialLink>> = mutableSocialLinks
private val mutableSimilarEvents = MutableLiveData<Set<Event>>()
val similarEvents: LiveData<Set<Event>> = mutableSimilarEvents
private val mutableSimilarEvents = MutableLiveData<List<Event>>()
val similarEvents: LiveData<List<Event>> = mutableSimilarEvents
private val mutableOrders = MutableLiveData<List<Order>>()
val orders: LiveData<List<Order>> = mutableOrders

Expand Down Expand Up @@ -144,24 +144,17 @@ class EventDetailsViewModel(
if (topicId != -1L) {
similarEventsFlowable = similarEventsFlowable.zipWith(eventService.getSimilarEvents(topicId),
BiFunction { firstList: List<Event>, secondList: List<Event> ->
val similarList = mutableListOf<Event>()
similarList.addAll(firstList)
similarList.addAll(secondList)
similarList
val similarList = mutableSetOf<Event>()
similarList.addAll(firstList + secondList)
similarList.toList()
})
}
compositeDisposable += similarEventsFlowable
.withDefaultSchedulers()
.distinctUntilChanged()
.subscribe({ events ->
val list = events.filter { it.id != eventId }
val oldList = mutableSimilarEvents.value
val similarEventList = mutableSetOf<Event>()
similarEventList.addAll(list)
oldList?.let {
similarEventList.addAll(it)
}
mutableSimilarEvents.value = similarEventList
mutableSimilarEvents.value = list
}, {
Timber.e(it, "Error fetching similar events")
mutablePopMessage.value = resource.getString(R.string.error_fetching_event_section_message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class OrderCompletedViewModel(private val eventService: EventService, private va
val event: LiveData<Event> = mutableEvent
private val mutableProgress = MutableLiveData<Boolean>()
val progress: LiveData<Boolean> = mutableProgress
private val mutableSimilarEvents = MutableLiveData<Set<Event>>()
val similarEvents: LiveData<Set<Event>> = mutableSimilarEvents
private val mutableSimilarEvents = MutableLiveData<List<Event>>()
val similarEvents: LiveData<List<Event>> = mutableSimilarEvents

fun loadEvent(id: Long) {
if (id.equals(-1)) {
Expand All @@ -51,10 +51,9 @@ class OrderCompletedViewModel(private val eventService: EventService, private va
if (topicId != -1L) {
similarEventsFlowable = similarEventsFlowable.zipWith(eventService.getSimilarEvents(topicId),
BiFunction { firstList: List<Event>, secondList: List<Event> ->
val similarList = mutableListOf<Event>()
similarList.addAll(firstList)
similarList.addAll(secondList)
similarList
val similarList = mutableSetOf<Event>()
similarList.addAll(firstList + secondList)
similarList.toList()
})
}

Expand All @@ -63,14 +62,7 @@ class OrderCompletedViewModel(private val eventService: EventService, private va
.distinctUntilChanged()
.subscribe({ events ->
val list = events.filter { it.id != eventId }
val oldList = mutableSimilarEvents.value
val similarEventList = mutableSetOf<Event>()
similarEventList.addAll(list)
oldList?.let {
similarEventList.addAll(it)
}
mutableProgress.value = false
mutableSimilarEvents.value = similarEventList
mutableSimilarEvents.value = list
}, {
Timber.e(it, "Error fetching similar events")
})
Expand Down