Skip to content

Commit

Permalink
Merge pull request #326 from joeloewi7178/development
Browse files Browse the repository at this point in the history
  • Loading branch information
joeloewi7178 authored Jan 11, 2024
2 parents 30ef100 + 2b8651e commit 4b2bf1e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 48
versionCode = 49
versionName = "1.2.2"
targetSdk = 34

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object UtilModule {
this
}
}
.okHttpClient { okHttpClient }
.okHttpClient(okHttpClient)
.placeholder(R.drawable.image_placeholder)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,21 @@ class AttendanceDetailViewModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) {
_deleteAttendanceState.value = ILCE.Loading
_deleteAttendanceState.value = runCatching {
deleteAttendanceUseCase(getOneAttendanceUseCase(attendanceId).attendance)
val attendance = getOneAttendanceUseCase(attendanceId).attendance

listOf(
attendance.checkSessionWorkerName,
attendance.attendCheckInEventWorkerName,
attendance.oneTimeAttendCheckInEventWorkerName
).map { it.toString() }.map { uniqueWorkName ->
workManager.cancelUniqueWork(uniqueWorkName)
}

workManager.cancelWorkById(attendance.checkSessionWorkerId)

alarmScheduler.cancelCheckInAlarm(attendance.id)

deleteAttendanceUseCase(attendance)
Unit
}.foldAsILCE()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.joeloewi.croissant.worker
import android.content.Context
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import com.google.firebase.Firebase
import com.google.firebase.crashlytics.crashlytics
Expand Down Expand Up @@ -46,7 +47,14 @@ class CheckSessionWorker @AssistedInject constructor(
_attendanceId.runCatching {
takeIf { it != Long.MIN_VALUE }!!
}.mapCatching { attendanceId ->
getOneAttendanceUseCase(attendanceId)
val attendance = runCatching { getOneAttendanceUseCase(attendanceId) }.getOrNull()

if (attendance == null) {
WorkManager.getInstance(context).cancelWorkById(id)
return@withContext Result.failure()
} else {
attendance
}
}.mapCatching { attendanceWithAllValues ->
getUserFullInfoHoYoLABUseCase(attendanceWithAllValues.attendance.cookie).getOrThrow()
}.fold(
Expand Down

0 comments on commit 4b2bf1e

Please sign in to comment.