Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ respect-server/log/
/respect-datalayer-repository/log/respect-server.log
/respect-lib-shared/log/respect-server.log
/.maestro/video-downloader/cypress/screenshots

/.maestro/flows/.maestro/screenshots
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ fun AssignmentDetailScreen(
timeZoneId = TimeZone.currentSystemDefault().id,
)

RespectDataLoadHost(uiState.assignmentProgress) {
RespectDataLoadHost(uiState.assignmentProgress,
modifier = Modifier.fillMaxSize().padding(vertical = 10.dp)
) {
Box(modifier = Modifier.fillMaxSize()) {
Column(modifier = Modifier.fillMaxSize()) {
if (!uiState.isFullscreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package world.respect.shared.viewmodel.assignment.detail
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import androidx.navigation.toRoute
import io.github.aakira.napier.Napier
import io.ktor.http.Url
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
Expand All @@ -23,6 +25,7 @@ import org.koin.core.scope.Scope
import world.respect.datalayer.SchoolDataSource
import world.respect.datalayer.db.school.ext.isAdminOrTeacher
import world.respect.datalayer.db.school.ext.isStudent
import world.respect.lib.dataloadstate.DataErrorResult
import world.respect.lib.dataloadstate.DataLoadParams
import world.respect.lib.dataloadstate.DataLoadState
import world.respect.lib.dataloadstate.DataLoadingState
Expand Down Expand Up @@ -234,9 +237,13 @@ class AssignmentDetailViewModel(
progress = state.data.progress.sortedBy { it.actor.name?.lowercase() ?: "" }
)
)
} else state
} else {
state
}
}.catch { e ->
Napier.w("Assignment progress flow error", e)
emit(DataErrorResult(error = e))
}.shareIn(viewModelScope, SharingStarted.Lazily)

launch {
assignmentProgressFlow.collect { assignmentAndProgress ->
_appUiState.update { appState ->
Expand Down Expand Up @@ -299,7 +306,17 @@ class AssignmentDetailViewModel(
fun taskInfoFlowFor(url: Url): Flow<DataLoadState<OpdsPublication>> {
return schoolDataSource.opdsPublicationDataSource.getByUrlAsFlow(
url = url, params = DataLoadParams(), null, null
)
).map { state ->
val remoteErr = state.remoteState as? DataErrorResult<*>
if(remoteErr != null) {
DataErrorResult(error = remoteErr.error, metaInfo = state.metaInfo, localState = state.localState, remoteState = state.remoteState)
} else {
state
}
}.catch { e ->
Napier.w("failed loading task info for $url", e)
emit(DataErrorResult(error = e))
}
}

fun onClickTask(activity: XapiActivity) {
Expand Down Expand Up @@ -340,4 +357,4 @@ class AssignmentDetailViewModel(
)
)
}
}
}