Skip to content

Commit

Permalink
fix: download new scripts on repo changed
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcoding810 committed Nov 30, 2024
1 parent 917cd1f commit 7b88943
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/src/main/java/com/paulcoding/hviewer/network/Github.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ object Github {
withContext(Dispatchers.IO) {
try {
_stateFlow.update { it.copy(isLoading = true) }
if (_stateFlow.value.remoteUrl != Preferences.getRemote()) {
Preferences.setRemote(_stateFlow.value.remoteUrl)
downloadAndGetConfig()
return@withContext
}
if (!appContext.configFile.exists()) {
log("Config file not exist, downloading from remote...", "check update")
downloadAndGetConfig()
Expand Down Expand Up @@ -134,7 +139,6 @@ object Github {
kotlin.runCatching {
val (owner, repo) = parseRepo(url)
val remoteUrl = "https://github.com/$owner/$repo/"
Preferences.setRemote(remoteUrl)
_stateFlow.update { it.copy(remoteUrl = remoteUrl) }
}.onFailure {
setError(it)
Expand Down

0 comments on commit 7b88943

Please sign in to comment.