Add observer when Fragment is created first only
MODIFY
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/BottomSheetDaySessionsFragment.kt
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/BottomSheetDaySessionsFragment.kt
@@ -131,9 +131,6 @@ class BottomSheetDaySessionsFragment : DaggerFragment() {
?.startDayText ?: return@changed
binding.sessionsBottomSheetTitle.text = titleText
}
- sessionPagesStore.firstLoadSessions.changed(viewLifecycleOwner) {
- scrollToCurrentSession()
- }
sessionPagesStore.filters.changed(viewLifecycleOwner) {
binding.isFiltered = it.isFiltered()
}
@@ -155,6 +152,12 @@ class BottomSheetDaySessionsFragment : DaggerFragment() {
scrollToCurrentSession()
}
}
+
+ if (savedInstanceState == null) {
+ sessionPagesStore.firstLoadSessions.observe(viewLifecycleOwner) {
+ scrollToCurrentSession()
+ }
+ }
}
override fun onDestroyView() {

MODIFY
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/store/SessionPagesStore.kt
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/store/SessionPagesStore.kt
@@ -127,9 +127,10 @@ class SessionPagesStore @Inject constructor(
.map { it.sessionPage }
.toSingleLiveData(SessionPage.pages[0])
- val firstLoadSessions = filteredSessions
+ val firstLoadSessions: LiveData<Unit> = filteredSessions
.nonNull()
.filter { it.isNotEmpty() }
+ .map { Unit }
.first()
fun filteredSessionsByDay(day: Int): LiveData<List<Session>> {

Add observer when Fragment is created first only