From d17d2c8417f5e8fdbdc0caf11f87c1388dc8fa96 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Mon, 25 Nov 2019 22:53:37 +0100 Subject: [PATCH] [APIv2/Librus] Fix looking for the lesson in getting homework. --- .../librus/data/synergia/LibrusSynergiaHomework.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/synergia/LibrusSynergiaHomework.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/synergia/LibrusSynergiaHomework.kt index 228001c7..5e423215 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/synergia/LibrusSynergiaHomework.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/librus/data/synergia/LibrusSynergiaHomework.kt @@ -56,16 +56,16 @@ class LibrusSynergiaHomework(override val data: DataLibrus, val onSuccess: () -> val id = "/podglad/([0-9]+)'".toRegex().find( elements[9].select("input").attr("onclick") )?.get(1)?.toLong() ?: return@forEachIndexed - val startTime = data.lessonList.singleOrNull { - it.weekDay == eventDate.weekDay && it.subjectId == subjectId - }?.startTime + + val lessons = data.db.timetableDao().getForDateNow(profileId, eventDate) + val startTime = lessons.firstOrNull { it.subjectId == subjectId }?.startTime val moreInfo = graphElements[2 * i + 1].select("td[title]") .attr("title").trim() val description = "Treść: (.*)".toRegex(RegexOption.DOT_MATCHES_ALL).find(moreInfo) ?.get(1)?.replace("".toRegex(), "\n")?.trim() - val notified = when (profile?.empty) { + val seen = when (profile?.empty) { true -> true else -> eventDate < Date.getToday() } @@ -89,8 +89,8 @@ class LibrusSynergiaHomework(override val data: DataLibrus, val onSuccess: () -> profileId, Metadata.TYPE_HOMEWORK, id, - notified, - notified, + seen, + seen, addedDate )) }