mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-13 13:41:58 +00:00
app: use github api to check updates
This commit is contained in:
@@ -14,7 +14,8 @@ class ManagerInstallDialog : MarkDownDialog() {
|
||||
private val svc get() = ServiceLocator.networkService
|
||||
|
||||
override suspend fun getMarkdownText(): String {
|
||||
val text = svc.fetchString(Info.remote.magisk.note)
|
||||
val str = Info.remote.magisk.note
|
||||
val text = if (str.startsWith("http", true)) svc.fetchString(str) else str
|
||||
// Cache the changelog
|
||||
AppContext.cacheDir.listFiles { _, name -> name.endsWith(".md") }.orEmpty().forEach {
|
||||
it.delete()
|
||||
|
||||
@@ -71,11 +71,14 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val file = File(AppContext.cacheDir, "${BuildConfig.APP_VERSION_CODE}.md")
|
||||
val note = Info.remote.magisk.note
|
||||
val text = when {
|
||||
file.exists() -> file.readText()
|
||||
Const.Url.CHANGELOG_URL.isEmpty() -> ""
|
||||
Const.APP_IS_CANARY && note.isEmpty() -> ""
|
||||
Const.APP_IS_CANARY && !note.startsWith("http", true) -> note
|
||||
else -> {
|
||||
val str = svc.fetchString(Const.Url.CHANGELOG_URL)
|
||||
val url = if (Const.APP_IS_CANARY) note else Const.Url.CHANGELOG_URL
|
||||
val str = svc.fetchString(url)
|
||||
file.writeText(str)
|
||||
str
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user