forked from github/wulkanowy-mirror
Mitigate disappearing room numbers in timetable (#265)
This commit is contained in:

committed by
Rafał Borcz

parent
dcab8df4b9
commit
1b7db4bfbb
@ -33,7 +33,14 @@ class TimetableRepository @Inject constructor(
|
||||
.toSingle(emptyList())
|
||||
.doOnSuccess { oldTimetable ->
|
||||
local.deleteTimetable(oldTimetable - newTimetable)
|
||||
local.saveTimetable(newTimetable - oldTimetable)
|
||||
local.saveTimetable((newTimetable - oldTimetable).map { item ->
|
||||
item.apply {
|
||||
if (room.isEmpty()) {
|
||||
oldTimetable.singleOrNull { it.start == this.start && it.room.isNotEmpty() }
|
||||
?.let { return@map copy(room = it.room) }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}.flatMap {
|
||||
local.getTimetable(semester, dates.first, dates.second)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.wulkanowy.utils
|
||||
|
||||
import org.threeten.bp.DateTimeUtils
|
||||
import org.threeten.bp.DayOfWeek.FRIDAY
|
||||
import org.threeten.bp.DayOfWeek.MONDAY
|
||||
import org.threeten.bp.DayOfWeek.SATURDAY
|
||||
@ -36,6 +37,8 @@ fun LocalDate.toFormattedString(format: String = DATE_PATTERN): String = this.fo
|
||||
|
||||
fun LocalDateTime.toFormattedString(format: String = DATE_PATTERN): String = this.format(ofPattern(format))
|
||||
|
||||
fun LocalDateTime.toDate(): Date = DateTimeUtils.toDate(atZone(ZoneId.systemDefault()).toInstant())
|
||||
|
||||
/**
|
||||
* https://github.com/ThreeTen/threetenbp/issues/55
|
||||
*/
|
||||
|
Reference in New Issue
Block a user