Skip to content

Commit

Permalink
Update BlockBlogUseCase.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Agoni-0 authored Oct 25, 2024
1 parent 1ca33ad commit 2419256
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class BlockBlogUseCase @Inject constructor(
feedId: Long
) = flow {
// Blocking multiple sites in parallel isn't supported as the user would lose the ability to undo the action
if (continuation == null) {
if (!networkUtilsWrapper.isNetworkAvailable()) {
emit(NoNetwork)
} else {
performAction(blogId, feedId)
}
} else {
emit(AlreadyRunning)
}
if (continuation == null) {
if (!networkUtilsWrapper.isNetworkAvailable()) {
emit(NoNetwork)
} else {
performAction(blogId, feedId)
}
} else {
emit(AlreadyRunning)
}
}

private suspend fun FlowCollector<BlockSiteState>.performAction(
Expand All @@ -55,13 +55,13 @@ class BlockBlogUseCase @Inject constructor(
val blockedBlogData = readerBlogActionsWrapper.blockBlogFromReaderLocal(blogId, feedId)
emit(SiteBlockedInLocalDb(blockedBlogData))

val succeeded = blockBlogAndWaitForResult(blockedBlogData)
val succeeded = blockBlogAndWaitForResult(blockedBlogData)

if (succeeded) {
emit(Success)
} else {
emit(RequestFailed)
}
if (succeeded) {
emit(Success)
} else {
emit(RequestFailed)
}
}

private suspend fun blockBlogAndWaitForResult(blockedBlogResult: BlockedBlogResult): Boolean {
Expand Down

0 comments on commit 2419256

Please sign in to comment.