Skip to content
Snippets Groups Projects
Commit c997bb12 authored by Jonas Broeckmann's avatar Jonas Broeckmann
Browse files

Fix Hiwi tracker crashes

parent 2d343827
No related branches found
No related tags found
1 merge request!2Official API
......@@ -28,12 +28,12 @@ class Credentials(
@Suppress("RedundantIf")
private fun verifyDebug(): Boolean {
if (!BuildConfig.DEBUG) return false
if (!EnableDebugCredentials) return false
return true
}
private fun getDebugUserLogin(): Login? {
if (!verifyDebug()) return null
if (!EnableDebugUserCredentials) return null
@Suppress("USELESS_ELVIS")
val username = BuildConfig.I11_PORTAL_DEBUG_USERNAME ?: return null
@Suppress("USELESS_ELVIS")
......@@ -44,6 +44,7 @@ class Credentials(
private fun getDebugDeviceCredentials(): DeviceCredentials? {
if (!verifyDebug()) return null
if (!EnableDebugDeviceCredentials) return null
@Suppress("USELESS_ELVIS")
val deviceId = BuildConfig.I11_KAFFEEKASSE_DEBUG_DEVICEID ?: return null
@Suppress("USELESS_ELVIS")
......@@ -109,6 +110,7 @@ class Credentials(
}
companion object {
private const val EnableDebugCredentials = true
private const val EnableDebugUserCredentials = true
private const val EnableDebugDeviceCredentials = false
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ class HiwiTrackerRepository(
suspend fun submitWorkEntry(workEntry: WorkEntry) {
if (!workEntry.isValid) return
scraper.submitWorkEntry(workEntry)
dataByMonth[workEntry.date.toMonthKey()]?.markDirty()
markFutureMonthsDirty(workEntry.date.toMonthKey())
}
suspend fun deleteWorkEntry(workEntryId: Int) {
......@@ -47,4 +47,9 @@ class HiwiTrackerRepository(
dataByMonth.values.forEach { it.markDirty() }
}
private fun markFutureMonthsDirty(month: MonthKey) {
dataByMonth.entries.forEach { (key, data) ->
if (key >= month) data.markDirty()
}
}
}
\ No newline at end of file
......@@ -86,7 +86,6 @@ import net.novagamestudios.common_utils.compose.components.CircularProgressIndic
import net.novagamestudios.common_utils.compose.components.RowCenter
import net.novagamestudios.common_utils.debug
import net.novagamestudios.common_utils.verbose
import net.novagamestudios.kaffeekasse.repositories.RepositoryProvider
import net.novagamestudios.kaffeekasse.api.hiwi_tracker.model.MonthDataResponse
import net.novagamestudios.kaffeekasse.model.date_time.format
import net.novagamestudios.kaffeekasse.model.hiwi_tracker.MonthKey
......@@ -94,9 +93,10 @@ import net.novagamestudios.kaffeekasse.model.hiwi_tracker.MonthKey.Companion.toM
import net.novagamestudios.kaffeekasse.model.hiwi_tracker.WorkEntry
import net.novagamestudios.kaffeekasse.model.session.Session
import net.novagamestudios.kaffeekasse.repositories.MutableSettingsStore
import net.novagamestudios.kaffeekasse.repositories.RepositoryProvider
import net.novagamestudios.kaffeekasse.repositories.i11.HiwiTrackerRepository
import net.novagamestudios.kaffeekasse.ui.navigation.HiwiTrackerNavigation
import net.novagamestudios.kaffeekasse.ui.kaffeekasse.components.FailureRetryScreen
import net.novagamestudios.kaffeekasse.ui.navigation.HiwiTrackerNavigation
import net.novagamestudios.kaffeekasse.ui.theme.disabled
import net.novagamestudios.kaffeekasse.ui.util.HorizontalKeyedPager
import net.novagamestudios.kaffeekasse.ui.util.HorizontalPagedLayout
......@@ -213,7 +213,7 @@ fun Overview(
vm: OverviewViewModel,
modifier: Modifier = Modifier
) = PullToRefreshBox(
refreshing = { vm.dataForMonthState(vm.currentMonth).isLoading },
refreshing = { false },
onRefresh = { vm.refreshMonth(vm.currentMonth) },
modifier.fillMaxSize()
) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment