You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Added feature that prevents repositories from being downloaded every single time that user requests to show Module/Download fragment unless requested by user
This commit is contained in:
@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.data.database
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
import com.skoumal.teanity.database.BaseDao
|
||||
import com.topjohnwu.magisk.model.entity.Repository
|
||||
|
||||
@@ -9,6 +10,7 @@ import com.topjohnwu.magisk.model.entity.Repository
|
||||
interface RepositoryDao : BaseDao<Repository> {
|
||||
|
||||
@Query("DELETE FROM repos")
|
||||
@Transaction
|
||||
override fun deleteAll()
|
||||
|
||||
@Query("SELECT * FROM repos")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.topjohnwu.magisk.data.repository
|
||||
|
||||
import android.content.Context
|
||||
import com.skoumal.teanity.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.data.database.RepositoryDao
|
||||
import com.topjohnwu.magisk.data.network.GithubApiServices
|
||||
import com.topjohnwu.magisk.data.network.GithubRawApiServices
|
||||
@@ -23,9 +22,9 @@ class ModuleRepository(
|
||||
private val repoDao: RepositoryDao
|
||||
) {
|
||||
|
||||
fun fetchModules() = Single.fromCallable { repoDao.fetchAll() }
|
||||
.flatMap { if (it.isEmpty()) fetchRemoteRepos() else it.toSingle() }
|
||||
.doOnSuccess { fetchRemoteRepos().subscribeK() } // cache changed for next time or next hot reload
|
||||
fun fetchModules(force: Boolean = false) =
|
||||
if (force) fetchRemoteRepos() else Single.fromCallable { repoDao.fetchAll() }
|
||||
.flatMap { if (it.isEmpty()) fetchRemoteRepos() else it.toSingle() }
|
||||
|
||||
private fun fetchRemoteRepos() = fetchAllRepos()
|
||||
.map {
|
||||
|
||||
Reference in New Issue
Block a user