fix: always empty notes

This commit is contained in:
sadorowo 2024-01-03 19:41:05 +01:00
parent ee906d02ae
commit 43a01e4e04
4 changed files with 20 additions and 5 deletions

View File

@ -27,8 +27,8 @@ android {
testApplicationId "io.github.tests.wulkanowy" testApplicationId "io.github.tests.wulkanowy"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 34 targetSdkVersion 34
versionCode 140 versionCode 138
versionName "2.3.0" versionName "2.2.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "app_name", "Wulkanowy" resValue "string", "app_name", "Wulkanowy"

View File

@ -4,6 +4,7 @@ import io.github.wulkanowy.data.db.dao.NoteDao
import io.github.wulkanowy.data.db.entities.Note import io.github.wulkanowy.data.db.entities.Note
import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Semester
import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.data.mappers.mapToEntities
import io.github.wulkanowy.data.networkBoundResource import io.github.wulkanowy.data.networkBoundResource
import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.Sdk
import io.github.wulkanowy.ui.modules.dashboard.DashboardItem import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
@ -49,7 +50,17 @@ class NoteRepository @Inject constructor(
noteDb.loadAll(student.studentId) noteDb.loadAll(student.studentId)
} }
}, },
fetch = { listOf<Note>() }, fetch = {
val notesHidden = preferencesRepository
.selectedHiddenSettingTiles
.contains(DashboardItem.HiddenSettingTile.NOTES)
sdk.init(student)
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
.getNotes()
.filter { !notesHidden }
.mapToEntities(semester)
},
saveFetchResult = { old, new -> saveFetchResult = { old, new ->
noteDb.deleteAll(old uniqueSubtract new) noteDb.deleteAll(old uniqueSubtract new)
noteDb.insertAll((new uniqueSubtract old).onEach { noteDb.insertAll((new uniqueSubtract old).onEach {

View File

@ -273,6 +273,10 @@ class DashboardPresenter @Inject constructor(
private fun loadHorizontalGroup(student: Student, forceRefresh: Boolean) { private fun loadHorizontalGroup(student: Student, forceRefresh: Boolean) {
flow { flow {
val fake = preferencesRepository
.selectedHiddenSettingTiles
.contains(DashboardItem.HiddenSettingTile.ATTENDANCE)
val selectedTiles = selectedDashboardTiles val selectedTiles = selectedDashboardTiles
val flowSuccess = flowOf(Resource.Success(null)) val flowSuccess = flowOf(Resource.Success(null))
@ -324,7 +328,7 @@ class DashboardPresenter @Inject constructor(
} else null } else null
}, },
attendancePercentage = DashboardItem.HorizontalGroup.Cell( attendancePercentage = DashboardItem.HorizontalGroup.Cell(
data = attendanceResource.dataOrNull?.calculatePercentage(), data = attendanceResource.dataOrNull?.calculatePercentage(fake),
error = attendanceResource.errorOrNull != null, error = attendanceResource.errorOrNull != null,
isLoading = attendanceResource is Resource.Loading, isLoading = attendanceResource is Resource.Loading,
), ),

View File

@ -1,6 +1,6 @@
buildscript { buildscript {
ext { ext {
kotlin_version = '1.9.22' kotlin_version = '1.9.21'
about_libraries = '10.10.0' about_libraries = '10.10.0'
hilt_version = '2.50' hilt_version = '2.50'
} }