Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Conversation

@d4rken
Copy link
Member

@d4rken d4rken commented Nov 27, 2020

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.

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.
@d4rken d4rken added bug Something isn't working maintainers Tag pull requests created by maintainers labels Nov 27, 2020
@d4rken d4rken added this to the 1.8.0 milestone Nov 27, 2020
@d4rken d4rken requested a review from a team November 27, 2020 14:29
Comment on lines +51 to +57
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

Copy link
Member

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.

Suggested change
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

Copy link
Member Author

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.

@ralfgehrer ralfgehrer assigned chris-cwa and ralfgehrer and unassigned chris-cwa Nov 30, 2020
Copy link
Contributor

@BMItr BMItr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm, nothing to complain.
passed local testing
image

Copy link
Contributor

@ralfgehrer ralfgehrer left a 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)

Copy link
Contributor

@ralfgehrer ralfgehrer left a 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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

40.6% 40.6% Coverage
0.0% 0.0% Duplication

@harambasicluka harambasicluka merged commit 35f353d into release/1.8.x Nov 30, 2020
@harambasicluka harambasicluka deleted the fix/4036-notification-loop branch November 30, 2020 14:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working maintainers Tag pull requests created by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants