Minor cleanup

This commit is contained in:
Jobobby04 2022-10-18 17:52:47 -04:00
parent 49d5d797b3
commit 82793b7a41
4 changed files with 9 additions and 6 deletions

View File

@ -282,6 +282,7 @@ class PreMigrationController(bundle: Bundle? = null) :
val disabledSources = sourcePreferences.disabledSources().get() val disabledSources = sourcePreferences.disabledSources().get()
.mapNotNull { it.toLongOrNull() } .mapNotNull { it.toLongOrNull() }
val sources = sourceManager.getVisibleCatalogueSources() val sources = sourceManager.getVisibleCatalogueSources()
.asSequence()
.filterIsInstance<HttpSource>() .filterIsInstance<HttpSource>()
.filter { it.lang in languages } .filter { it.lang in languages }
.sortedBy { "(${it.lang}) ${it.name}" } .sortedBy { "(${it.lang}) ${it.name}" }
@ -295,11 +296,14 @@ class PreMigrationController(bundle: Bundle? = null) :
), ),
) )
} }
.toList()
return sources return sources
.filter { it.sourceEnabled } .filter { it.sourceEnabled }
.sortedBy { sourcesSaved.indexOf(it.source.id) } + .sortedBy { sourcesSaved.indexOf(it.source.id) }
sources.filterNot { it.sourceEnabled } .plus(
sources.filterNot { it.sourceEnabled },
)
} }
fun isEnabled( fun isEnabled(

View File

@ -14,7 +14,7 @@ class MigratingManga(
parentContext: CoroutineContext, parentContext: CoroutineContext,
val getManga: suspend (SearchResult.Result) -> Manga?, val getManga: suspend (SearchResult.Result) -> Manga?,
val getChapterInfo: suspend (SearchResult.Result) -> ChapterInfo, val getChapterInfo: suspend (SearchResult.Result) -> ChapterInfo,
val getSourceName: (Manga) -> String?, val getSourceName: (Manga) -> String,
) { ) {
val migrationScope = CoroutineScope(parentContext + SupervisorJob() + Dispatchers.Default) val migrationScope = CoroutineScope(parentContext + SupervisorJob() + Dispatchers.Default)

View File

@ -101,7 +101,7 @@ class MigrationProcessHolder(
} }
if (resultManga != null) { if (resultManga != null) {
val (sourceName, latestChapter) = withIOContext { val (sourceName, latestChapter) = withIOContext {
val sourceNameAsync = async { migrateManga.getSourceName(resultManga).orEmpty() } val sourceNameAsync = async { migrateManga.getSourceName(resultManga) }
val latestChapterAsync = async { migrateManga.getChapterInfo(searchResult as SearchResult.Result) } val latestChapterAsync = async { migrateManga.getChapterInfo(searchResult as SearchResult.Result) }
sourceNameAsync.await() to latestChapterAsync.await() sourceNameAsync.await() to latestChapterAsync.await()
} }

View File

@ -166,7 +166,7 @@ class BrowserActionActivity : AppCompatActivity() {
// Rob demo credentials // Rob demo credentials
.url("https://speech-to-text-demo.ng.bluemix.net/api/v1/credentials") .url("https://speech-to-text-demo.ng.bluemix.net/api/v1/credentials")
.build(), .build(),
).await().parseAs<JsonObject>()["token"]!!.jsonPrimitive.content ).await().parseAs<JsonObject>()["token"]!!.jsonPrimitive.content,
) )
} catch (e: Exception) { } catch (e: Exception) {
xLogE("Failed to get credentials", e) xLogE("Failed to get credentials", e)
@ -269,7 +269,6 @@ class BrowserActionActivity : AppCompatActivity() {
} catch (e: Exception) { } catch (e: Exception) {
captchaSolveFail() captchaSolveFail()
} }
} }
} else { } else {
binding.webview.postDelayed( binding.webview.postDelayed(