refactor(build): adopt Slack lints

This commit is contained in:
Harsh Shandilya 2023-09-28 14:09:09 +05:30
parent eb449740eb
commit ed32186984
No known key found for this signature in database
10 changed files with 31 additions and 11 deletions

View file

@ -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)

View file

@ -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 }
}

View file

@ -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

View file

@ -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,