add time to task when saving session report
This commit is contained in:
parent
e333a0f626
commit
d4c017ef1b
1 changed files with 6 additions and 0 deletions
|
@ -1,9 +1,11 @@
|
||||||
package be.ugent.sel.studeez.screens.session_recap
|
package be.ugent.sel.studeez.screens.session_recap
|
||||||
|
|
||||||
|
import be.ugent.sel.studeez.data.SelectedTask
|
||||||
import be.ugent.sel.studeez.data.SessionReportState
|
import be.ugent.sel.studeez.data.SessionReportState
|
||||||
import be.ugent.sel.studeez.data.local.models.SessionReport
|
import be.ugent.sel.studeez.data.local.models.SessionReport
|
||||||
import be.ugent.sel.studeez.domain.LogService
|
import be.ugent.sel.studeez.domain.LogService
|
||||||
import be.ugent.sel.studeez.domain.SessionDAO
|
import be.ugent.sel.studeez.domain.SessionDAO
|
||||||
|
import be.ugent.sel.studeez.domain.TaskDAO
|
||||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
@ -13,6 +15,8 @@ import javax.inject.Inject
|
||||||
class SessionRecapViewModel @Inject constructor(
|
class SessionRecapViewModel @Inject constructor(
|
||||||
sessionReportState: SessionReportState,
|
sessionReportState: SessionReportState,
|
||||||
private val sessionDAO: SessionDAO,
|
private val sessionDAO: SessionDAO,
|
||||||
|
private val taskDAO: TaskDAO,
|
||||||
|
private val selectedTask: SelectedTask,
|
||||||
logService: LogService
|
logService: LogService
|
||||||
) : StudeezViewModel(logService) {
|
) : StudeezViewModel(logService) {
|
||||||
|
|
||||||
|
@ -24,6 +28,8 @@ class SessionRecapViewModel @Inject constructor(
|
||||||
|
|
||||||
fun saveSession(open: (String, String) -> Unit) {
|
fun saveSession(open: (String, String) -> Unit) {
|
||||||
sessionDAO.saveSession(getSessionReport())
|
sessionDAO.saveSession(getSessionReport())
|
||||||
|
val newTask = selectedTask().copy(time = selectedTask().time + report.studyTime)
|
||||||
|
taskDAO.updateTask(newTask)
|
||||||
open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP)
|
open(StudeezDestinations.HOME_SCREEN, StudeezDestinations.SESSION_RECAP)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue