mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 03:37:05 +05:30
refactor(build): adopt Slack lints
This commit is contained in:
parent
eb449740eb
commit
ed32186984
10 changed files with 31 additions and 11 deletions
|
@ -46,6 +46,9 @@ licensee {
|
|||
allow("MIT")
|
||||
ignoreDependencies("org.commonmark") { because("Commonmark is BSD licensed") }
|
||||
allowUrl("https://jsoup.org/license") { because("Jsoup is MIT licensed") }
|
||||
allowUrl("https://opensource.org/licenses/isc-license.txt") {
|
||||
because("kotlin-result is ISC licensed")
|
||||
}
|
||||
}
|
||||
|
||||
moduleGraphAssert {
|
||||
|
|
|
@ -262,7 +262,10 @@ fun LobstersApp(
|
|||
navDeepLink { uriPattern = "$uri/s/${Destinations.Comments.placeholder}" },
|
||||
),
|
||||
) { backStackEntry ->
|
||||
val postId = requireNotNull(backStackEntry.arguments?.getString("postId"))
|
||||
val postId =
|
||||
requireNotNull(backStackEntry.arguments?.getString("postId")) {
|
||||
"Navigating to ${Destinations.Comments.route} without necessary 'postId' argument"
|
||||
}
|
||||
setWebUri("https://lobste.rs/s/$postId")
|
||||
CommentsPage(
|
||||
postId = postId,
|
||||
|
@ -278,7 +281,10 @@ fun LobstersApp(
|
|||
deepLinks =
|
||||
listOf(navDeepLink { uriPattern = "$uri/u/${Destinations.User.placeholder}" }),
|
||||
) { backStackEntry ->
|
||||
val username = requireNotNull(backStackEntry.arguments?.getString("username"))
|
||||
val username =
|
||||
requireNotNull(backStackEntry.arguments?.getString("username")) {
|
||||
"Navigating to ${Destinations.User.route} without necessary 'username' argument"
|
||||
}
|
||||
setWebUri("https://lobste.rs/u/$username")
|
||||
UserProfile(
|
||||
username = username,
|
||||
|
|
|
@ -62,6 +62,7 @@ class AndroidCommonPlugin : Plugin<Project> {
|
|||
val catalog = project.extensions.getByType<VersionCatalogsExtension>()
|
||||
val libs = catalog.named("libs")
|
||||
project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get())
|
||||
project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-lints").get())
|
||||
}
|
||||
|
||||
private fun Project.configureSlimTests() {
|
||||
|
|
|
@ -50,6 +50,7 @@ dependencies {
|
|||
implementation(libs.compose.richtext.ui)
|
||||
implementation(libs.kotlinx.collections.immutable)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.kotlinResult.coroutines)
|
||||
implementation(libs.napier)
|
||||
|
||||
compileOnly(libs.androidx.compose.ui.tooling.preview)
|
||||
|
|
|
@ -37,6 +37,8 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.michaelbull.result.coroutines.runSuspendCatching
|
||||
import com.github.michaelbull.result.onSuccess
|
||||
import dev.msfjarvis.claw.common.posts.PostActions
|
||||
import dev.msfjarvis.claw.common.posts.PostTitle
|
||||
import dev.msfjarvis.claw.common.posts.Submitter
|
||||
|
@ -61,7 +63,7 @@ internal fun CommentsHeader(
|
|||
produceState(
|
||||
initialValue = LinkMetadata(postDetails.url, null),
|
||||
) {
|
||||
runCatching { postActions.getLinkMetadata(postDetails.url) }
|
||||
runSuspendCatching { postActions.getLinkMetadata(postDetails.url) }
|
||||
.onSuccess { metadata -> value = metadata }
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.michaelbull.result.coroutines.runSuspendCatching
|
||||
import com.github.michaelbull.result.fold
|
||||
import dev.msfjarvis.claw.common.NetworkState
|
||||
import dev.msfjarvis.claw.common.NetworkState.Error
|
||||
import dev.msfjarvis.claw.common.NetworkState.Loading
|
||||
|
@ -109,10 +111,10 @@ fun CommentsPage(
|
|||
) {
|
||||
val postDetails by
|
||||
produceState<NetworkState>(Loading) {
|
||||
runCatching { postActions.getComments(postId) }
|
||||
runSuspendCatching { postActions.getComments(postId) }
|
||||
.fold(
|
||||
onSuccess = { details -> value = Success(details) },
|
||||
onFailure = { value = Error(error = it, description = "Failed to load comments") }
|
||||
success = { details -> value = Success(details) },
|
||||
failure = { value = Error(error = it, description = "Failed to load comments") },
|
||||
)
|
||||
}
|
||||
val commentState by
|
||||
|
|
|
@ -25,6 +25,8 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.michaelbull.result.coroutines.runSuspendCatching
|
||||
import com.github.michaelbull.result.fold
|
||||
import dev.msfjarvis.claw.common.NetworkState
|
||||
import dev.msfjarvis.claw.common.NetworkState.Error
|
||||
import dev.msfjarvis.claw.common.NetworkState.Loading
|
||||
|
@ -44,10 +46,10 @@ fun UserProfile(
|
|||
) {
|
||||
val user by
|
||||
produceState<NetworkState>(Loading) {
|
||||
runCatching { getProfile(username) }
|
||||
runSuspendCatching { getProfile(username) }
|
||||
.fold(
|
||||
onSuccess = { profile -> value = Success(profile) },
|
||||
onFailure = {
|
||||
success = { profile -> value = Success(profile) },
|
||||
failure = {
|
||||
value =
|
||||
Error(
|
||||
error = it,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*/
|
||||
@file:Suppress("InjectDispatcher") // False-positive
|
||||
@file:Suppress("RawDispatchersUse") // False-positive
|
||||
|
||||
package dev.msfjarvis.claw.core.coroutines
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import kotlinx.coroutines.CoroutineDispatcher
|
|||
@ContributesTo(ApplicationScope::class)
|
||||
interface CoroutineDispatcherModule {
|
||||
|
||||
@Binds fun DefaultDispatcherProvider.bind(): DispatcherProvider
|
||||
@Binds fun bindDispatcherProvider(impl: DefaultDispatcherProvider): DispatcherProvider
|
||||
|
||||
companion object {
|
||||
@[Provides IODispatcher]
|
||||
|
|
|
@ -10,6 +10,7 @@ glance = "1.0.0"
|
|||
junit = "5.10.0"
|
||||
konvert = "2.3.0"
|
||||
kotlin = "1.9.10"
|
||||
kotlinResult = "1.1.18"
|
||||
retrofit = "2.9.0"
|
||||
richtext = "0.17.0"
|
||||
sentry-sdk = "6.29.0"
|
||||
|
@ -78,6 +79,7 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
|
|||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
|
||||
kotlinResult-coroutines = { module = "com.michael-bull.kotlin-result:kotlin-result-coroutines", version.ref = "kotlinResult" }
|
||||
napier = "io.github.aakira:napier:2.6.1"
|
||||
okhttp-bom = "com.squareup.okhttp3:okhttp-bom:4.11.0"
|
||||
okhttp-core = { module = "com.squareup.okhttp3:okhttp" }
|
||||
|
@ -88,6 +90,7 @@ retrofit-kotlinxSerializationConverter = "com.jakewharton.retrofit:retrofit2-kot
|
|||
sentry-bom = { module = "io.sentry:sentry-bom", version.ref = "sentry-sdk" }
|
||||
sentry-okhttp = { module = "io.sentry:sentry-android-okhttp", version.ref = "sentry-sdk" }
|
||||
slack-compose-lints = "com.slack.lint.compose:compose-lint-checks:1.2.0"
|
||||
slack-lints = "com.slack.lint:slack-lint-checks:0.6.0"
|
||||
sqldelight-androidDriver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-extensions-coroutines = { module = "app.cash.sqldelight:coroutines-extensions-jvm", version.ref = "sqldelight" }
|
||||
sqldelight-jvmDriver = { module = "app.cash.sqldelight:sqlite-driver", version.ref = "sqldelight" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue