Skip to content

Commit

Permalink
take into account if user has opened the app but not dismissed the ba…
Browse files Browse the repository at this point in the history
…nner
  • Loading branch information
ktiniatros committed Nov 26, 2021
1 parent 0a3791a commit 5184add
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import nl.rijksoverheid.ctr.holder.persistence.WorkerManagerWrapper
import nl.rijksoverheid.ctr.holder.persistence.database.HolderDatabase
import nl.rijksoverheid.ctr.holder.persistence.database.entities.*
import nl.rijksoverheid.ctr.holder.persistence.database.migration.TestResultsMigrationManager
import nl.rijksoverheid.ctr.holder.ui.create_qr.usecases.CheckNewRecoveryValidityUseCase
import nl.rijksoverheid.ctr.holder.ui.create_qr.usecases.SecretKeyUseCase
import nl.rijksoverheid.ctr.introduction.introductionModule
import nl.rijksoverheid.ctr.shared.MobileCoreWrapper
Expand Down Expand Up @@ -41,6 +42,7 @@ open class HolderApplication : SharedApplication(), Configuration.Provider {
private val appConfigStorageManager: AppConfigStorageManager by inject()
private val mobileCoreWrapper: MobileCoreWrapper by inject()
private val workerManagerWrapper: WorkerManagerWrapper by inject()
private val checkNewRecoveryValidityUseCase: CheckNewRecoveryValidityUseCase by inject()

private val holderModules = listOf(
storageModule,
Expand Down Expand Up @@ -100,6 +102,11 @@ open class HolderApplication : SharedApplication(), Configuration.Provider {
}

testResultsMigrationManager.removeOldCredential()

// only for 2.5.2 hotfix
if (BuildConfig.VERSION_NAME.contains("2.5.2") ) {
checkNewRecoveryValidityUseCase.checkIfNeedToReAllowRecoveryExtensionCheck()
}
}

if (appConfigStorageManager.areConfigFilesPresentInFilesFolder()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.time.ZoneId
*/
interface CheckNewRecoveryValidityUseCase {
suspend fun check()
suspend fun checkIfNeedToReAllowRecoveryExtensionCheck()
}

class CheckNewRecoveryValidityUseCaseImpl(
Expand Down Expand Up @@ -73,4 +74,26 @@ class CheckNewRecoveryValidityUseCaseImpl(
persistenceManager.setShouldCheckRecoveryGreenCardRevisedValidity(false)
}
}

/**
* If the user has upgraded to 2.5.1, we have done the check already, so he will see
* the banner to extend his recovery. We need to allow the check again, in order to
* prevent showing the banner for the recovery paper certificates.
*/
override suspend fun checkIfNeedToReAllowRecoveryExtensionCheck() {
if (persistenceManager.getShouldCheckRecoveryGreenCardRevisedValidity()) {
return
}
val allEvents = holderDatabase.eventGroupDao().getAll()

removeExpiredEventsUseCase.execute(allEvents)

val hasPaperRecoveryEvent = allEvents.any { it.type is OriginType.Recovery && it.providerIdentifier == PROVIDER_IDENTIFIER_DCC }

if (hasPaperRecoveryEvent) {
persistenceManager.setShowExtendDomesticRecoveryInfoCard(false)
persistenceManager.setShowRecoverDomesticRecoveryInfoCard(false)
persistenceManager.setShouldCheckRecoveryGreenCardRevisedValidity(true)
}
}
}

0 comments on commit 5184add

Please sign in to comment.