From 216c639a239999bc9c608251c4589ba3c32b20b8 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 23 Aug 2022 20:40:54 +0200 Subject: [PATCH] Closes #23 --- .../apps/readerforselfossv2/android/HomeActivity.kt | 3 ++- .../apps/readerforselfossv2/utils/ModelConverters.kt | 12 ++---------- .../readerforselfossv2/repository/RepositoryImpl.kt | 2 +- .../apps/readerforselfossv2/utils/EntityUtils.kt | 6 +++--- .../apps/readerforselfossv2/utils/ModelConverters.kt | 6 +----- .../apps/readerforselfossv2/utils/ModelConverters.kt | 12 +----------- .../apps/readerforselfossv2/utils/ModelConverters.kt | 12 +----------- 7 files changed, 11 insertions(+), 42 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 184129a..a2496d5 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -40,6 +40,7 @@ import bou.amine.apps.readerforselfossv2.dao.ACTION import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.model.SelfossModel import bou.amine.apps.readerforselfossv2.utils.ItemType +import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded import bou.amine.apps.readerforselfossv2.utils.longHash import bou.amine.apps.readerforselfossv2.utils.toView import com.ashokvarma.bottomnavigation.BottomNavigationBar @@ -473,7 +474,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar val drawerItem = PrimaryDrawerItem() .apply { - nameText = it.getTitleDecoded() + nameText = it.tag.getHtmlDecoded() identifier = it.tag.longHash() iconDrawable = gd badgeStyle = BadgeStyle().apply { diff --git a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt index 6c6dc63..2c9a1e8 100644 --- a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt +++ b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt @@ -3,14 +3,6 @@ package bou.amine.apps.readerforselfossv2.utils import android.text.Html import bou.amine.apps.readerforselfossv2.model.SelfossModel -actual fun SelfossModel.Item.getTitleDecoded(): String { - return Html.fromHtml(title).toString() -} - -actual fun SelfossModel.Item.getSourceTitle(): String { - return Html.fromHtml(sourcetitle).toString() -} - -actual fun SelfossModel.Source.getTitleDecoded(): String { - return Html.fromHtml(title).toString() +actual fun String.getHtmlDecoded(): String { + return Html.fromHtml(this).toString() } \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index d4fc47c..e4e7d90 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -416,7 +416,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails db.actionsQueries.insertAction(articleid, read, unread, starred, unstarred) private fun updateDBItem(item: SelfossModel.Item) = - db.itemsQueries.updateItem(item.datetime, item.getTitleDecoded(), item.content, item.unread, item.starred, item.thumbnail, item.icon, item.link, item.sourcetitle, item.tags.joinToString(","), item.id.toString()) + db.itemsQueries.updateItem(item.datetime, item.title.getHtmlDecoded(), item.content, item.unread, item.starred, item.thumbnail, item.icon, item.link, item.sourcetitle, item.tags.joinToString(","), item.id.toString()) suspend fun tryToCacheItemsAndGetNewOnes(): List? { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/EntityUtils.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/EntityUtils.kt index 5269ba7..9407a79 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/EntityUtils.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/EntityUtils.kt @@ -25,7 +25,7 @@ fun SOURCE.toView(): SelfossModel.Source = fun SelfossModel.Source.toEntity(): SOURCE = SOURCE( this.id.toString(), - this.getTitleDecoded(), + this.title.getHtmlDecoded(), this.tags.joinToString(","), this.spout, this.error, @@ -58,13 +58,13 @@ fun SelfossModel.Item.toEntity(): ITEM = ITEM( this.id.toString(), this.datetime, - this.getTitleDecoded(), + this.title.getHtmlDecoded(), this.content, this.unread, this.starred, this.thumbnail, this.icon, this.link, - this.getSourceTitle(), + this.title.getHtmlDecoded(), this.tags.joinToString(",") ) \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt index 881c1f1..ba0a6c6 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt @@ -1,7 +1,3 @@ package bou.amine.apps.readerforselfossv2.utils -import bou.amine.apps.readerforselfossv2.model.SelfossModel - -expect fun SelfossModel.Source.getTitleDecoded(): String -expect fun SelfossModel.Item.getTitleDecoded(): String -expect fun SelfossModel.Item.getSourceTitle(): String \ No newline at end of file +expect fun String.getHtmlDecoded(): String \ No newline at end of file diff --git a/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt b/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt index e40e4e1..c149800 100644 --- a/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt +++ b/shared/src/iosArm64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt @@ -1,15 +1,5 @@ package bou.amine.apps.readerforselfossv2.utils -import bou.amine.apps.readerforselfossv2.model.SelfossModel - -actual fun SelfossModel.Item.getTitleDecoded(): String { - TODO("Not yet implemented") -} - -actual fun SelfossModel.Item.getSourceTitle(): String { - TODO("Not yet implemented") -} - -actual fun SelfossModel.Source.getTitleDecoded(): String { +actual fun String.getHtmlDecoded(): String { TODO("Not yet implemented") } \ No newline at end of file diff --git a/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt b/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt index e40e4e1..c149800 100644 --- a/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt +++ b/shared/src/iosX64Main/kotlin/bou/amine/apps/readerforselfossv2/utils/ModelConverters.kt @@ -1,15 +1,5 @@ package bou.amine.apps.readerforselfossv2.utils -import bou.amine.apps.readerforselfossv2.model.SelfossModel - -actual fun SelfossModel.Item.getTitleDecoded(): String { - TODO("Not yet implemented") -} - -actual fun SelfossModel.Item.getSourceTitle(): String { - TODO("Not yet implemented") -} - -actual fun SelfossModel.Source.getTitleDecoded(): String { +actual fun String.getHtmlDecoded(): String { TODO("Not yet implemented") } \ No newline at end of file