Skip to content

Commit

Permalink
feat: remove commits list
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Jan 14, 2024
1 parent 5339459 commit b47a1b4
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.aliucord.manager.network.utils.transform
class GithubRepository(
private val service: AliucordGithubService,
) {
suspend fun getCommits(page: Int = 0) = service.getCommits(page)
suspend fun getContributors() = service.getContributors()
.transform { it.sortedByDescending(GithubUser::contributions) }

Expand Down
24 changes: 0 additions & 24 deletions app/src/main/kotlin/com/aliucord/manager/network/dto/Commit.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AliucordGithubService(
}
}

suspend fun getCommits(page: Int = 0) = github.getCommits(ORG, MAIN_REPO, page)
suspend fun getManagerReleases() = github.getReleases(ORG, MANAGER_REPO)
suspend fun getContributors() = github.getContributors(ORG, MAIN_REPO)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
package com.aliucord.manager.network.service

import com.aliucord.manager.network.dto.*
import com.aliucord.manager.network.dto.GithubRelease
import com.aliucord.manager.network.dto.GithubUser
import com.aliucord.manager.network.utils.ApiResponse
import io.ktor.client.request.parameter
import io.ktor.client.request.url
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class GithubService(
private val http: HttpService,
) {
suspend fun getCommits(owner: String, repo: String, page: Int = 0): ApiResponse<List<Commit>> {
return withContext(Dispatchers.IO) {
http.request {
url("https://api.github.com/repos/$owner/$repo/commits")
parameter("page", page)
}
}
}

suspend fun getContributors(owner: String, repo: String): ApiResponse<List<GithubUser>> {
return withContext(Dispatchers.IO) {
http.request {
Expand All @@ -34,12 +25,4 @@ class GithubService(
}
}
}

suspend fun getLatestRelease(owner: String, repo: String): ApiResponse<GithubRelease> {
return withContext(Dispatchers.IO) {
http.request {
url("https://api.github.com/repos/$owner/$repo/releases/latest")
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import android.app.Application
import android.content.pm.PackageManager
import android.util.Log
import androidx.compose.runtime.*
import androidx.paging.*
import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import com.aliucord.manager.BuildConfig
import com.aliucord.manager.R
import com.aliucord.manager.domain.manager.PreferencesManager
import com.aliucord.manager.domain.repository.GithubRepository
import com.aliucord.manager.installer.util.uninstallApk
import com.aliucord.manager.network.dto.Commit
import com.aliucord.manager.network.utils.fold
import com.aliucord.manager.ui.util.DiscordVersion
import com.aliucord.manager.util.getPackageVersion
Expand All @@ -30,32 +28,6 @@ class HomeModel(
var installedVersion by mutableStateOf<DiscordVersion>(DiscordVersion.None)
private set

val commits = Pager(PagingConfig(pageSize = 30)) {
object : PagingSource<Int, Commit>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Commit> {
val page = params.key ?: 0

return github.getCommits(page).fold(
success = { commits ->
val prevKey = if (page > 0) page - 1 else null
val nextKey = if (commits.isNotEmpty()) page + 1 else null

LoadResult.Page(
data = commits,
prevKey = prevKey,
nextKey = nextKey
)
},
fail = { LoadResult.Error(it) }
)
}

override fun getRefreshKey(state: PagingState<Int, Commit>) = state.anchorPosition?.let {
state.closestPageToPosition(it)?.prevKey?.plus(1) ?: state.closestPageToPosition(it)?.nextKey?.minus(1)
}
}
}.flow.cachedIn(screenModelScope)

init {
screenModelScope.launch(Dispatchers.IO) {
_fetchInstalledVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import com.aliucord.manager.BuildConfig
import com.aliucord.manager.R
import com.aliucord.manager.ui.components.dialogs.InstallerDialog
import com.aliucord.manager.ui.components.home.CommitList
import com.aliucord.manager.ui.components.home.InfoCard
import com.aliucord.manager.ui.screens.about.AboutScreen
import com.aliucord.manager.ui.screens.install.InstallScreen
Expand Down Expand Up @@ -73,11 +72,6 @@ class HomeScreen : Screen {
onLaunchClick = model::launchAliucord,
onUninstallClick = model::uninstallAliucord
)

CommitList(
commits = model.commits,
onRetry = { model.fetchSupportedVersion() }
)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/kotlin/com/aliucord/manager/ui/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ inline fun <T> Iterable<T>.joinToAnnotatedString(
* (assuming `annotation_name` is not changed between translations),
* when rendering [annotationHandler] will be called on each `annotation_name` and expected to return a target style on it.
*/
@Suppress("NOTHING_TO_INLINE")
@Composable
inline fun annotatingStringResource(
@StringRes id: Int,
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ accompanist-systemUiController = { module = "com.google.accompanist:accompanist-
androidx-activity = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx-splashscreen" }
androidx-paging = "androidx.paging:paging-compose:1.0.0-alpha17" # TODO: remove paging

# Compose
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose" }
Expand Down Expand Up @@ -79,7 +78,6 @@ androidx = [
"androidx-core",
"androidx-activity",
"androidx-splashscreen",
"androidx-paging",
]
compose = [
"compose-runtime",
Expand Down

0 comments on commit b47a1b4

Please sign in to comment.