Manga database classes, api url change, fix source id
This commit is contained in:
@@ -68,9 +68,9 @@ fun installAPK(apkName: String): Int {
|
||||
// name = httpSource.name
|
||||
// this.extension = ExtensionEntity.find { ExtensionsTable.name eq extension.name }.first().id
|
||||
// }
|
||||
if (SourcesTable.select { SourcesTable.sourceId eq httpSource.id }.count() == 0L) {
|
||||
if (SourcesTable.select { SourcesTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourcesTable.insert {
|
||||
it[this.sourceId] = httpSource.id
|
||||
it[this.id] = httpSource.id
|
||||
it[name] = httpSource.name
|
||||
it[this.lang] = httpSource.lang
|
||||
it[extension] = extensionId
|
||||
@@ -86,9 +86,9 @@ fun installAPK(apkName: String): Int {
|
||||
transaction {
|
||||
sourceFactory.createSources().forEachIndexed { index, source ->
|
||||
val httpSource = source as HttpSource
|
||||
if (SourcesTable.select { SourcesTable.sourceId eq httpSource.id }.count() == 0L) {
|
||||
if (SourcesTable.select { SourcesTable.id eq httpSource.id }.count() == 0L) {
|
||||
SourcesTable.insert {
|
||||
it[this.sourceId] = httpSource.id
|
||||
it[this.id] = httpSource.id
|
||||
it[name] = httpSource.name
|
||||
it[this.lang] = httpSource.lang
|
||||
it[extension] = extensionId
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
package ir.armor.tachidesk.util
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.net.URLClassLoader
|
||||
|
||||
fun getHttpSource(sourceId: Long): HttpSource {
|
||||
return transaction {
|
||||
val sourceRecord = SourceEntity.find { SourcesTable.sourceId eq sourceId }.first()
|
||||
val sourceRecord = SourceEntity.get(sourceId)
|
||||
val extensionId = sourceRecord.extension.id.value
|
||||
val extensionRecord = ExtensionEntity.get(extensionId)
|
||||
val apkName = extensionRecord.apkName
|
||||
@@ -44,11 +44,11 @@ fun getSourceList(): List<SourceDataClass> {
|
||||
return transaction {
|
||||
return@transaction SourcesTable.selectAll().map {
|
||||
SourceDataClass(
|
||||
it[SourcesTable.sourceId],
|
||||
it[SourcesTable.id].value,
|
||||
it[SourcesTable.name],
|
||||
it[SourcesTable.lang],
|
||||
ExtensionsTable.select { ExtensionsTable.id eq it[SourcesTable.extension] }.first()[ExtensionsTable.iconUrl],
|
||||
getHttpSource(it[SourcesTable.sourceId]).supportsLatest
|
||||
getHttpSource(it[SourcesTable.id].value).supportsLatest
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user