-
Notifications
You must be signed in to change notification settings - Fork 487
Fix possible notification loop (EXPOSUREAPP-4036) #1750
Conversation
This fixed the issue that if no new risk level calculation happened, and the last one triggered a notification, killing and restarting the app would also trigger a notification.
| val lastCheckedResult = riskLevelSettings.lastChangeCheckedRiskLevelTimestamp | ||
| if (lastCheckedResult == newResult.calculatedAt) { | ||
| Timber.d("We already checked this risk level change, skipping further checks.") | ||
| return | ||
| } | ||
| riskLevelSettings.lastChangeCheckedRiskLevelTimestamp = newResult.calculatedAt | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any advantage to create the variable lastCheckedResult ? can we not directly compare riskLevelSettings.lastChangeCheckedRiskLevelTimestamp in the condition?
The comment is more for an information seeking purpose rather that a suggestion.
| val lastCheckedResult = riskLevelSettings.lastChangeCheckedRiskLevelTimestamp | |
| if (lastCheckedResult == newResult.calculatedAt) { | |
| Timber.d("We already checked this risk level change, skipping further checks.") | |
| return | |
| } | |
| riskLevelSettings.lastChangeCheckedRiskLevelTimestamp = newResult.calculatedAt | |
| if (iskLevelSettings.lastChangeCheckedRiskLevelTimestamp == newResult.calculatedAt) { | |
| Timber.d("We already checked this risk level change, skipping further checks.") | |
| return | |
| } | |
| riskLevelSettings.lastChangeCheckedRiskLevelTimestamp = newResult.calculatedAt | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readability, inlining the variable exceeds our maximum line length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ralfgehrer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine. Testing now. Should also fix another issue (EXPOSUREAPP-4050)
ralfgehrer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works like a charm
|
Kudos, SonarCloud Quality Gate passed! |
This fixes the issue that if no new risk level calculation happened, and the last one triggered a notification, killing and restarting the app would also trigger a notification.
To test this you'd have to get to a state where the last risk level calculations were LOW_RISK -> HIGH_RISK, and then just kill the app process and open the app again.
Also: While debugging this I noticed a few cryptic log messages which needed explicit tags.