Removed the 5 min dialogue
This commit is contained in:
@@ -188,11 +188,6 @@ class HomeViewModel @Inject constructor(
|
||||
val attendanceDoc = getAttendanceDocument(userId, currentDate)
|
||||
|
||||
if (attendanceDoc?.exists() == true) {
|
||||
val checkIn = attendanceDoc.getString("checkIn1") // Using first check-in for time validation
|
||||
if (checkIn != null && !isTimeDifferenceGreaterThanMinutes(givenTimeStr = checkIn, minutes = 0L)) {
|
||||
handleError("Wait 5 minutes before logging off")
|
||||
return@launch
|
||||
}
|
||||
handleExistingAttendance(attendanceDoc)
|
||||
} else {
|
||||
handleNewAttendance(userId, currentDate)
|
||||
@@ -278,16 +273,16 @@ class HomeViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isTimeDifferenceGreaterThanMinutes(givenTimeStr: String, currentTimeStr: String = formatTimestamp(Timestamp.now()), minutes: Long): Boolean {
|
||||
val formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy hh:mm:ss a")
|
||||
|
||||
val givenTime = LocalDateTime.parse(givenTimeStr, formatter)
|
||||
val currentTime = LocalDateTime.parse(currentTimeStr, formatter)
|
||||
|
||||
val timeDifference = abs(ChronoUnit.MINUTES.between(givenTime, currentTime))
|
||||
|
||||
return timeDifference > minutes
|
||||
}
|
||||
// private fun isTimeDifferenceGreaterThanMinutes(givenTimeStr: String, currentTimeStr: String = formatTimestamp(Timestamp.now()), minutes: Long): Boolean {
|
||||
// val formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy hh:mm:ss a")
|
||||
//
|
||||
// val givenTime = LocalDateTime.parse(givenTimeStr, formatter)
|
||||
// val currentTime = LocalDateTime.parse(currentTimeStr, formatter)
|
||||
//
|
||||
// val timeDifference = abs(ChronoUnit.MINUTES.between(givenTime, currentTime))
|
||||
//
|
||||
// return timeDifference > minutes
|
||||
// }
|
||||
|
||||
private suspend fun handleNewAttendance(userId: String, currentDate: String) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user