Skip to content

Commit

Permalink
fix: code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Leach <[email protected]>
  • Loading branch information
jleach committed Jul 22, 2024
1 parent eb2fe2c commit e5c1fcc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ export const expirationOverrideInMinutes = (
enabledAt: Date,
autoDisableRemoteLoggingIntervalInMinutes: number
): number => {
const now = new Date()
const autoDisableRemoteLoggingMinutesAgo = new Date(now.getTime() - autoDisableRemoteLoggingIntervalInMinutes * 60000)
const isOlderThanAutoDisableInterval = enabledAt < autoDisableRemoteLoggingMinutesAgo
const now = Date.now()
const enabledAtTime = enabledAt.getTime()
const autoDisableIntervalInMilliseconds = autoDisableRemoteLoggingIntervalInMinutes * 60000

if (isOlderThanAutoDisableInterval) {
if (enabledAtTime < now - autoDisableIntervalInMilliseconds) {
return 0
}

const diffInMilliseconds = now.getTime() - enabledAt.getTime()
const diffInMinutes = Math.floor(diffInMilliseconds / 1000 / 60)
const expirationOverrideInMinutes = autoDisableRemoteLoggingIntervalInMinutes - diffInMinutes

return expirationOverrideInMinutes
const diffInMinutes = Math.floor((now - enabledAtTime) / 60000)
return autoDisableRemoteLoggingIntervalInMinutes - diffInMinutes
}

0 comments on commit e5c1fcc

Please sign in to comment.