Skip to content

Commit

Permalink
Add initial support to check org repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nonproto committed Dec 1, 2023
1 parent a787370 commit 4ae4d04
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,36 @@ class AppUpdateChecker {

return withIOContext {
val result = with(json) {
networkService.client
.newCall(GET(LATEST_RELEASE_URL))
.await()
.parseAs<GithubRelease>()
.let {
preferences.lastAppCheck().set(Date().time)
try {
networkService.client.newCall(GET(LATEST_RELEASE_URL_NEW))
.await()
.parseAs<GithubRelease>()
.let {
preferences.lastAppCheck().set(Date().time)

// Check if latest version is different from current version
if (Version(it.version).isHigherThan(BuildConfig.VERSION_NAME)) {
AppUpdateResult.NewUpdate(it)
} else {
AppUpdateResult.NoNewUpdate
// Check if latest version is different from current version
if (Version(it.version).isHigherThan(BuildConfig.VERSION_NAME)) {
AppUpdateResult.NewUpdate(it)
} else {
AppUpdateResult.NoNewUpdate
}
}
}
} catch (e: Exception) {
networkService.client
.newCall(GET(LATEST_RELEASE_URL))
.await()
.parseAs<GithubRelease>()
.let {
preferences.lastAppCheck().set(Date().time)

// Check if latest version is different from current version
if (Version(it.version).isHigherThan(BuildConfig.VERSION_NAME)) {
AppUpdateResult.NewUpdate(it)
} else {
AppUpdateResult.NoNewUpdate
}
}
}
}
if (doExtrasAfterNewUpdate && result is AppUpdateResult.NewUpdate) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
Expand All @@ -68,6 +84,10 @@ class AppUpdateChecker {
}
}

const val GITHUB_REPO_NEW: String = "nekomangaorg/neko"
const val LATEST_RELEASE_URL_NEW = "https://api.github.com/repos/$GITHUB_REPO_NEW/releases/latest"
const val RELEASE_URL_NEW = "https://github.com/$GITHUB_REPO_NEW/releases/tag/${BuildConfig.VERSION_NAME}"

const val GITHUB_REPO: String = "CarlosEsco/Neko"
const val LATEST_RELEASE_URL = "https://api.github.com/repos/$GITHUB_REPO/releases/latest"
const val RELEASE_URL = "https://github.com/$GITHUB_REPO/releases/tag/${BuildConfig.VERSION_NAME}"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.DpOffset
Expand Down Expand Up @@ -69,6 +68,7 @@ private fun CascadeColumnScope.Row(modifier: Modifier, item: SimpleDropDownItem,
},
)
}

is SimpleDropDownItem.Action -> {
Item(modifier = modifier, text = item.text.asString(), style = style, onClick = item.onClick, onDismiss = onDismiss)
}
Expand Down

0 comments on commit 4ae4d04

Please sign in to comment.