DB caching. #33

Merged
AmineB merged 9 commits from feature/sqldelight into master 2022-08-23 20:39:20 +00:00
7 changed files with 11 additions and 42 deletions
Showing only changes of commit 216c639a23 - Show all commits

View File

@ -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 {

View File

@ -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()
}

View File

@ -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<SelfossModel.Item>? {

View File

@ -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(",")
)

View File

@ -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
expect fun String.getHtmlDecoded(): String

View File

@ -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")
}

View File

@ -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")
}