Address misc. build warnings

This commit is contained in:
arkon
2022-08-10 23:26:34 -04:00
parent 24e64f52e2
commit d6f1534ee8
29 changed files with 96 additions and 37 deletions

View File

@@ -12,10 +12,10 @@ class CreateCategoryWithName(
private val categoryRepository: CategoryRepository,
) {
suspend fun await(name: String): Result = withContext(NonCancellable) await@{
suspend fun await(name: String): Result = withContext(NonCancellable) {
val categories = categoryRepository.getAll()
if (categories.anyWithName(name)) {
return@await Result.NameAlreadyExistsError
return@withContext Result.NameAlreadyExistsError
}
val nextOrder = categories.maxOfOrNull { it.order }?.plus(1) ?: 0

View File

@@ -11,12 +11,12 @@ class DeleteCategory(
private val categoryRepository: CategoryRepository,
) {
suspend fun await(categoryId: Long) = withContext(NonCancellable) await@{
suspend fun await(categoryId: Long) = withContext(NonCancellable) {
try {
categoryRepository.delete(categoryId)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@await Result.InternalError(e)
return@withContext Result.InternalError(e)
}
val categories = categoryRepository.getAll()

View File

@@ -13,10 +13,10 @@ class RenameCategory(
private val categoryRepository: CategoryRepository,
) {
suspend fun await(categoryId: Long, name: String) = withContext(NonCancellable) await@{
suspend fun await(categoryId: Long, name: String) = withContext(NonCancellable) {
val categories = categoryRepository.getAll()
if (categories.anyWithName(name)) {
return@await Result.NameAlreadyExistsError
return@withContext Result.NameAlreadyExistsError
}
val update = CategoryUpdate(

View File

@@ -12,12 +12,12 @@ class ReorderCategory(
private val categoryRepository: CategoryRepository,
) {
suspend fun await(categoryId: Long, newPosition: Int) = withContext(NonCancellable) await@{
suspend fun await(categoryId: Long, newPosition: Int) = withContext(NonCancellable) {
val categories = categoryRepository.getAll().filterNot(Category::isSystemCategory)
val currentIndex = categories.indexOfFirst { it.id == categoryId }
if (currentIndex == newPosition) {
return@await Result.Unchanged
return@withContext Result.Unchanged
}
val reorderedCategories = categories.toMutableList()

View File

@@ -27,11 +27,11 @@ class SetReadStatus(
)
}
suspend fun await(read: Boolean, vararg values: Chapter): Result = withContext(NonCancellable) f@{
suspend fun await(read: Boolean, vararg values: Chapter): Result = withContext(NonCancellable) {
val chapters = values.filterNot { it.read == read }
if (chapters.isEmpty()) {
return@f Result.NoChapters
return@withContext Result.NoChapters
}
val manga = chapters.fold(mutableSetOf<Manga>()) { acc, chapter ->
@@ -49,15 +49,15 @@ class SetReadStatus(
)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@f Result.InternalError(e)
return@withContext Result.InternalError(e)
}
if (read && preferences.removeAfterMarkedAsRead()) {
manga.forEach { manga ->
manga.forEach {
deleteDownload.awaitAll(
manga = manga,
manga = it,
values = chapters
.filter { manga.id == it.mangaId }
.filter { chapter -> it.id == chapter.mangaId }
.toTypedArray(),
)
}
@@ -66,8 +66,8 @@ class SetReadStatus(
Result.Success
}
suspend fun await(mangaId: Long, read: Boolean): Result = withContext(NonCancellable) f@{
return@f await(
suspend fun await(mangaId: Long, read: Boolean): Result = withContext(NonCancellable) {
await(
read = read,
values = chapterRepository
.getChapterByMangaId(mangaId)