mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: keep ambiguous update-channel guesses temporary
This commit is contained in:
1 parent
ac8957ae56
commit
9b176753cc
2 files changed
+38
-5
No files matched your search
@@ -200,9 +200,11 @@ object AppUpdates {
|
||||
fun message(context: Context): String = context.getString(text, *args)
|
||||
}
|
||||
|
||||
fun follow(context: Context, catalog: Catalog?): Follow {
|
||||
fun follow(context: Context, catalog: Catalog?): Follow = follow(context, catalog, installed())
|
||||
|
||||
internal fun follow(context: Context, catalog: Catalog?, me: Installed): Follow {
|
||||
stored(context)?.let { return it }
|
||||
val guess = guessFollow(catalog, installed())
|
||||
val guess = guessFollow(catalog, me)
|
||||
if (guess.certain) setFollow(context, guess.follow)
|
||||
return guess.follow
|
||||
}
|
||||
@@ -210,18 +212,18 @@ object AppUpdates {
|
||||
internal class Guess(val follow: Follow, val certain: Boolean)
|
||||
|
||||
/**
|
||||
* Stable and Preview builds of one commit are the same APK, so only the catalog can tell them apart. A guess that
|
||||
* the catalog does not prove (a stale cache, the gap before a release is catalogued) is used for this run only.
|
||||
* Stable and Preview builds of one commit are the same APK. Preview history can include older Stable releases,
|
||||
* so an overlapping older-build guess keeps the Stable default for this run without persisting it.
|
||||
*/
|
||||
internal fun guessFollow(catalog: Catalog?, me: Installed): Guess {
|
||||
if (me.pr != 0) return Guess(Follow(Channel.TEST, me.pr), true)
|
||||
val stable = catalog?.stable
|
||||
if (stable != null && isRunning(stable, me)) return Guess(Follow(Channel.STABLE), true)
|
||||
if (stable?.version?.let { compareVersions(me.version, it) < 0 } == true) return Guess(Follow(Channel.STABLE), true)
|
||||
val publishedPreview = catalog != null && me.updatable && (
|
||||
catalog.preview?.let { isRunning(it, me) } == true ||
|
||||
catalog.recentPreviews.any { matchesInstalledCommit(it.commit, me.commit) }
|
||||
)
|
||||
if (stable?.version?.let { compareVersions(me.version, it) < 0 } == true) return Guess(Follow(Channel.STABLE), !publishedPreview)
|
||||
return Guess(Follow(if (publishedPreview) Channel.NIGHTLY else Channel.STABLE), false)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user