forked from github/wulkanowy-mirror
Add student nick-or-name to notification summary (#1425)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package io.github.wulkanowy.ui.modules.debug.notification
|
||||
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.services.sync.notifications.NewConferenceNotification
|
||||
import io.github.wulkanowy.services.sync.notifications.NewExamNotification
|
||||
@ -21,6 +22,7 @@ import io.github.wulkanowy.ui.modules.debug.notification.mock.debugLuckyNumber
|
||||
import io.github.wulkanowy.ui.modules.debug.notification.mock.debugMessageItems
|
||||
import io.github.wulkanowy.ui.modules.debug.notification.mock.debugNoteItems
|
||||
import io.github.wulkanowy.ui.modules.debug.notification.mock.debugSchoolAnnouncementItems
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -38,36 +40,40 @@ class NotificationDebugPresenter @Inject constructor(
|
||||
) : BasePresenter<NotificationDebugView>(errorHandler, studentRepository) {
|
||||
|
||||
private val items = listOf(
|
||||
NotificationDebugItem(R.string.grade_title) {
|
||||
newGradeNotification.notifyDetails(debugGradeDetailsItems.take(it))
|
||||
NotificationDebugItem(R.string.grade_title) { n ->
|
||||
withStudent { newGradeNotification.notifyDetails(debugGradeDetailsItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.grade_summary_predicted_grade) {
|
||||
newGradeNotification.notifyPredicted(debugGradeSummaryItems.take(it))
|
||||
NotificationDebugItem(R.string.grade_summary_predicted_grade) { n ->
|
||||
withStudent { newGradeNotification.notifyPredicted(debugGradeSummaryItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.grade_summary_final_grade) {
|
||||
newGradeNotification.notifyFinal(debugGradeSummaryItems.take(it))
|
||||
NotificationDebugItem(R.string.grade_summary_final_grade) { n ->
|
||||
withStudent { newGradeNotification.notifyFinal(debugGradeSummaryItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.homework_title) {
|
||||
newHomeworkNotification.notify(debugHomeworkItems.take(it))
|
||||
NotificationDebugItem(R.string.homework_title) { n ->
|
||||
withStudent { newHomeworkNotification.notify(debugHomeworkItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.conferences_title) {
|
||||
newConferenceNotification.notify(debugConferenceItems.take(it))
|
||||
NotificationDebugItem(R.string.conferences_title) { n ->
|
||||
withStudent { newConferenceNotification.notify(debugConferenceItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.exam_title) {
|
||||
newExamNotification.notify(debugExamItems.take(it))
|
||||
NotificationDebugItem(R.string.exam_title) { n ->
|
||||
withStudent { newExamNotification.notify(debugExamItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.message_title) {
|
||||
newMessageNotification.notify(debugMessageItems.take(it))
|
||||
NotificationDebugItem(R.string.message_title) { n ->
|
||||
withStudent { newMessageNotification.notify(debugMessageItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.note_title) {
|
||||
newNoteNotification.notify(debugNoteItems.take(it))
|
||||
NotificationDebugItem(R.string.note_title) { n ->
|
||||
withStudent { newNoteNotification.notify(debugNoteItems.take(n), it) }
|
||||
},
|
||||
NotificationDebugItem(R.string.school_announcement_title) {
|
||||
newSchoolAnnouncementNotification.notify(debugSchoolAnnouncementItems.take(it))
|
||||
NotificationDebugItem(R.string.school_announcement_title) { n ->
|
||||
withStudent {
|
||||
newSchoolAnnouncementNotification.notify(debugSchoolAnnouncementItems.take(n), it)
|
||||
}
|
||||
},
|
||||
NotificationDebugItem(R.string.lucky_number_title) {
|
||||
repeat(it) {
|
||||
newLuckyNumberNotification.notify(debugLuckyNumber)
|
||||
NotificationDebugItem(R.string.lucky_number_title) { n ->
|
||||
withStudent {
|
||||
repeat(n) { _ ->
|
||||
newLuckyNumberNotification.notify(debugLuckyNumber, it)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
@ -80,4 +86,10 @@ class NotificationDebugPresenter @Inject constructor(
|
||||
setItems(items)
|
||||
}
|
||||
}
|
||||
|
||||
private fun withStudent(block: (Student) -> Unit) {
|
||||
launch {
|
||||
block(studentRepository.getCurrentStudent(false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user