Skip to content

Commit

Permalink
Update Linkding bad request handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fibelatti committed Dec 22, 2024
1 parent aefe0be commit 4fba36d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ object LinkdingModule {
accept(ContentType.Application.Json)
}

expectSuccess = true

install(unauthorizedPluginProvider.plugin)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import com.fibelatti.pinboard.features.posts.domain.usecase.AddPost
import com.fibelatti.pinboard.features.posts.domain.usecase.InvalidUrlException
import com.fibelatti.pinboard.features.tags.domain.model.Tag
import dagger.hilt.android.lifecycle.HiltViewModel
import io.ktor.client.plugins.ClientRequestException
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
Expand All @@ -34,7 +36,6 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.flow.withIndex
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class EditPostViewModel @Inject constructor(
Expand Down Expand Up @@ -111,7 +112,7 @@ class EditPostViewModel @Inject constructor(
currentState.copy(isLoading = false)
}
when (error) {
is InvalidUrlException -> {
is InvalidUrlException, is ClientRequestException -> {
_screenState.update { currentState ->
currentState.copy(
invalidUrlError = resourceProvider.getString(R.string.validation_error_invalid_url),
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

<!-- Validation -->
<string name="validation_error_empty_url">The URL cannot be empty</string>
<string name="validation_error_invalid_url">The URL is invalid</string>
<string name="validation_error_invalid_url">The URL is not accepted by the service</string>
<string name="validation_error_invalid_url_rationale">The URL could not be saved. Please verify that it is valid</string>
<string name="validation_error_empty_title">The title cannot be empty</string>

Expand Down

0 comments on commit 4fba36d

Please sign in to comment.