Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore skipped versions when using AlertType.force #405

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions Sources/Siren.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,25 @@ private extension Siren {
/// - currentAppStoreVersion: The curren version of the app in the App Store.
/// - model: The iTunes Lookup Model.
func determineIfAlertPresentationRulesAreSatisfied(forCurrentAppStoreVersion currentAppStoreVersion: String, andModel model: Model) {
// Did the user:
// - request to skip being prompted with version update alerts for a specific version
// - and is the latest App Store update the same version that was requested?
if let previouslySkippedVersion = UserDefaults.storedSkippedVersion,
let currentInstalledVersion = currentInstalledVersion,
!currentAppStoreVersion.isEmpty,
currentAppStoreVersion == previouslySkippedVersion {
resultsHandler?(.failure(.skipVersionUpdate(installedVersion: currentInstalledVersion,
appStoreVersion: currentAppStoreVersion)))
return
}

let updateType = DataParser.parseForUpdate(forInstalledVersion: currentInstalledVersion,
andAppStoreVersion: currentAppStoreVersion)
do {
let rules = try rulesManager.loadRulesForUpdateType(updateType)

// Did the user:
// - request to skip being prompted with version update alerts for a specific version
// - and is the latest App Store update the same version that was requested
// - and app is not forcing updates?
if let previouslySkippedVersion = UserDefaults.storedSkippedVersion,
let currentInstalledVersion = currentInstalledVersion,
!currentAppStoreVersion.isEmpty,
currentAppStoreVersion == previouslySkippedVersion,
rules.alertType != .force {
resultsHandler?(.failure(.skipVersionUpdate(installedVersion: currentInstalledVersion,
appStoreVersion: currentAppStoreVersion)))
return
}

if rules.frequency == .immediately {
presentAlert(withRules: rules, forCurrentAppStoreVersion: currentAppStoreVersion, model: model, andUpdateType: updateType)
} else {
Expand Down