attempt to solve and trace the crash in SnoozeParameters, as reported by users

This commit is contained in:
Johan Degraeve 2020-10-24 10:22:34 +02:00
parent c13d329bb4
commit 77b19728de
2 changed files with 18 additions and 2 deletions

View File

@ -430,6 +430,14 @@ public class AlertManager:NSObject {
// first check if the alert needs to fire, even if the alert would be snoozed, this will ensure logging.
if checkAlertAndFireHelper(alertKind) {return true}
// tracing to be deleted once crash issue is solved
if let snoozeTimeStamp = getSnoozeParameters(alertKind: alertKind).snoozeTimeStamp {
trace("in checkAlertGroupAndFire before calling getSnoozeValue, snoozeTimeStamp = %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, snoozeTimeStamp.description(with: .current))
} else {
trace("in checkAlertGroupAndFire before calling getSnoozeValue, snoozeTimeStamp = nil", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info)
}
trace("in checkAlertGroupAndFire before calling getSnoozeValue, snoozePeriodInMinutes = %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, getSnoozeParameters(alertKind: alertKind).snoozePeriodInMinutes.description)
// if alertKind is snoozed then we don't want to check the next alert (example if verylow is snoozed then don't check low)
if getSnoozeParameters(alertKind: alertKind).getSnoozeValue().isSnoozed {return false}
@ -472,6 +480,14 @@ public class AlertManager:NSObject {
/// will be initialized later
var minimumDelayInSecondsToUse:Int?
// tracing to be deleted once crash issue is solved
if let snoozeTimeStamp = getSnoozeParameters(alertKind: alertKind).snoozeTimeStamp {
trace("in checkAlertAndFire before calling getSnoozeValue, snoozeTimeStamp = %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, snoozeTimeStamp.description(with: .current))
} else {
trace("in checkAlertAndFire before calling getSnoozeValue, snoozeTimeStamp = nil", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info)
}
trace("in checkAlertAndFire before calling getSnoozeValue, snoozePeriodInMinutes = %{public}@", log: self.log, category: ConstantsLog.categoryAlertManager, type: .info, getSnoozeParameters(alertKind: alertKind).snoozePeriodInMinutes.description)
// check if snoozed
if getSnoozeParameters(alertKind: alertKind).getSnoozeValue().isSnoozed {

View File

@ -23,13 +23,13 @@ extension SnoozeParameters {
/// - remainingSeconds : if the alert is snoozed, then this says how many seconds remaining
public func getSnoozeValue() -> (isSnoozed:Bool, remainingSeconds:Int?) {
if let snoozeTimeStamp = snoozeTimeStamp, snoozePeriodInMinutes > 0 {
if Date(timeInterval: TimeInterval(snoozePeriodInMinutes * 60), since: snoozeTimeStamp) < Date() {
if Date(timeInterval: TimeInterval(Double(snoozePeriodInMinutes) * 60.0), since: snoozeTimeStamp) < Date() {
// snooze attributes are set, however they are expired
unSnooze() // set attributes to nil
return (false, nil)
} else {
// alert is still snoozed, calculate remaining seconds
return (true, Int((snoozeTimeStamp.toMillisecondsAsDouble() + Double(snoozePeriodInMinutes) * 60 * 1000 - Date().toMillisecondsAsDouble())/1000))
return (true, Int((snoozeTimeStamp.toMillisecondsAsDouble() + Double(snoozePeriodInMinutes) * 60.0 * 1000.0 - Date().toMillisecondsAsDouble())/1000.0))
}
} else {
return (false, nil)