fix(ios): kbd search now caches publishing data for result

This commit is contained in:
jahorton 2021-03-19 12:41:52 +07:00
parent 6c0bf45350
commit c5ee153c79
2 changed files with 19 additions and 0 deletions

View file

@ -190,6 +190,16 @@ public class KeymanPackage {
distributionMethod = downloadURL != nil ? .cloud : .unknown
self.downloadURL = downloadURL
}
// Used to store metadata for newly-downloaded results from the keyboard search.
// To save a version, we require also having a known URL.
internal init(downloadURL: URL, version: Version) {
self.timestampForLastQuery = NSDate().timeIntervalSince1970
self.latestVersion = version.fullString
self.downloadURL = downloadURL
distributionMethod = .cloud
}
}
static private let kmpFile = "kmp.json"

View file

@ -254,6 +254,15 @@ public class KeyboardSearchViewController: UIViewController, WKNavigationDelegat
// Illegal state - we already checked this.
fatalError()
}
// We've likely installed the package, and we already know
// the package's current publishing state - we literally just
// downloaded it from the cloud as part of the keyboard search.
//
// Why query later when we know the query's answer NOW?
let publishState = KeymanPackage.DistributionStateMetadata(downloadURL: packageURL, version: package.version)
Storage.active.userDefaults.cachedPackageQueryMetadata[package.key] = publishState
}
downloadManager.downloadPackage(withKey: packageKey, from: packageURL, withNotifications: true, completionBlock: downloadClosure)