Add home screen risk cell update button countdown #866
Conversation
* develop: Bump version + remove turkish Fixed wrong implementation of shouldPerformExposureDetection Removed custom html color definitions. Applied default color to attributed string. Only updated view when html parsing was successful. Applied default color. Fixed default font. chore: merge Risk & ExposureSubmission errors, remove duplicates as much as possible Risk Calculation Error Message Refinement Refactored ActivateCollectionViewCell configurator architecture. Removed HTML reload as it is not required anymore with current implementation thereby addressing JIRA ticket 1500. Inferred animation duration from loaded frames. Applied animated tracing status in configurator. Removed superfluous source line. Added animated icons for enabled tracing status.
let nextUpdate = riskProvider.nextExposureDetectionDate() | ||
countdownTimer = CountdownTimer(countdownTo: nextUpdate) | ||
countdownTimer?.delegate = self | ||
countdownTimer?.start() |
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.
I see, the timer invalidate
is only called in the CoutdownTimer class:
deinit {
timer?.invalidate()
timer = nil
}
My question is, if the app goes background, the Timer still runs? What will happened if the user opens the App after 2 days?
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.
thanks for bringing this up, I discovered a bug in my implementation where the timer was not stopped as I expected due to a reference cycle. I added a manual invalidate() method to make sure the timer is handled correctly.
Regarding the opening of the app after some time has passed: The timer is guaranteed to be up-to-date since the scene delegate will trigger the updateExposureState() method of the home VC when the app comes into foreground.
To make sure the timer does not drain the users battery when the app goes into background, I added a few lines that invalidate the handler when the app goes into background.
…onDate() to return meaningful date
… invalidate() method
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.
I have added some comments and cleaned up some of the code. Would be cool if you looked through these commits, and checked whether they make sense to you. Thanks! 👍
In case there aren't enough tests: Please make sure to add tests, cheers! 😄
...s/Home/HomeRiskCellConfigurator/HomeRiskCellConfigurators/HomeHighRiskCellConfigurator.swift
Outdated
Show resolved
Hide resolved
...ls/Home/HomeRiskCellConfigurator/HomeRiskCellConfigurators/HomeLowRiskCellConfigurator.swift
Outdated
Show resolved
Hide resolved
.../Home/HomeRiskCellConfigurator/HomeRiskCellConfigurators/HomeRiskLevelCellConfigurator.swift
Outdated
Show resolved
Hide resolved
...ome/HomeRiskCellConfigurator/HomeRiskCellConfigurators/HomeUnknownRiskCellConfigurator.swift
Outdated
Show resolved
Hide resolved
src/xcode/ENA/ENA/Source/Scenes/ExposureDetection/ExposureDetectionViewController.swift
Show resolved
Hide resolved
src/xcode/ENA/ENA/Source/Scenes/ExposureDetection/ExposureDetectionViewController.swift
Show resolved
Hide resolved
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.
Well done!💯
Description
This PR implements a countdown for the update button that is shown for the risk cell on the home screen. (see JIRA 1626)
Checklist