mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-02 20:54:19 -04:00
[db] update repo cache right after new repo got added
so we can use the new repo right away without waiting for DB to inform us about change. This is important if we want to show list of apps of a repo right after adding it.
This commit is contained in:
committed by
Michael Pöhn
parent
4bd033e6a7
commit
51d43f9004
@@ -143,7 +143,13 @@ public class RepoManager @JvmOverloads constructor(
|
||||
@AnyThread
|
||||
public fun addFetchedRepository() {
|
||||
GlobalScope.launch(coroutineContext) {
|
||||
repoAdder.addFetchedRepository()
|
||||
val addedRepo = repoAdder.addFetchedRepository()
|
||||
// if repo was added, update state right away, so it becomes available asap
|
||||
if (addedRepo != null) withContext(Dispatchers.Main) {
|
||||
_repositoriesState.value = _repositoriesState.value.toMutableList().apply {
|
||||
add(addedRepo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,9 +217,9 @@ internal class RepoAdder(
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
internal fun addFetchedRepository() {
|
||||
internal fun addFetchedRepository(): Repository? {
|
||||
// prevent double calls (e.g. caused by double tapping a UI button)
|
||||
if (addRepoState.compareAndSet(Adding, Adding)) return
|
||||
if (addRepoState.compareAndSet(Adding, Adding)) return null
|
||||
|
||||
// cancel fetch preview job, so it stops emitting new states
|
||||
fetchJob?.cancel()
|
||||
@@ -265,6 +265,7 @@ internal class RepoAdder(
|
||||
}
|
||||
}
|
||||
addRepoState.value = Added(modifiedRepo)
|
||||
return modifiedRepo
|
||||
}
|
||||
|
||||
internal fun abortAddingRepo() {
|
||||
|
||||
Reference in New Issue
Block a user