Commit f3705791 authored by Gabriel Luong's avatar Gabriel Luong
Browse files

Issue #7978: Part 2 - Rename TopSiteEntity to PinnedSiteEntity

parent 348b02c7
...@@ -43,7 +43,7 @@ class TopSiteDaoTest { ...@@ -43,7 +43,7 @@ class TopSiteDaoTest {
@Test @Test
fun testAddingTopSite() { fun testAddingTopSite() {
val topSite = TopSiteEntity( val topSite = PinnedSiteEntity(
title = "Mozilla", title = "Mozilla",
url = "https://www.mozilla.org", url = "https://www.mozilla.org",
isDefault = false, isDefault = false,
...@@ -65,7 +65,7 @@ class TopSiteDaoTest { ...@@ -65,7 +65,7 @@ class TopSiteDaoTest {
@Test @Test
fun testRemovingTopSite() { fun testRemovingTopSite() {
val topSite1 = TopSiteEntity( val topSite1 = PinnedSiteEntity(
title = "Mozilla", title = "Mozilla",
url = "https://www.mozilla.org", url = "https://www.mozilla.org",
isDefault = false, isDefault = false,
...@@ -74,7 +74,7 @@ class TopSiteDaoTest { ...@@ -74,7 +74,7 @@ class TopSiteDaoTest {
it.id = topSiteDao.insertTopSite(it) it.id = topSiteDao.insertTopSite(it)
} }
val topSite2 = TopSiteEntity( val topSite2 = PinnedSiteEntity(
title = "Firefox", title = "Firefox",
url = "https://www.firefox.com", url = "https://www.firefox.com",
isDefault = false, isDefault = false,
......
...@@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow ...@@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import mozilla.components.feature.top.sites.adapter.TopSiteAdapter import mozilla.components.feature.top.sites.adapter.TopSiteAdapter
import mozilla.components.feature.top.sites.db.TopSiteDatabase import mozilla.components.feature.top.sites.db.TopSiteDatabase
import mozilla.components.feature.top.sites.db.TopSiteEntity import mozilla.components.feature.top.sites.db.PinnedSiteEntity
/** /**
* A storage implementation for organizing top sites. * A storage implementation for organizing top sites.
...@@ -29,7 +29,7 @@ class PinnedSiteStorage( ...@@ -29,7 +29,7 @@ class PinnedSiteStorage(
* used to identify top sites that are added by the application. * used to identify top sites that are added by the application.
*/ */
fun addTopSite(title: String, url: String, isDefault: Boolean = false) { fun addTopSite(title: String, url: String, isDefault: Boolean = false) {
TopSiteEntity( PinnedSiteEntity(
title = title, title = title,
url = url, url = url,
isDefault = isDefault, isDefault = isDefault,
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
package mozilla.components.feature.top.sites.adapter package mozilla.components.feature.top.sites.adapter
import mozilla.components.feature.top.sites.TopSite import mozilla.components.feature.top.sites.TopSite
import mozilla.components.feature.top.sites.db.TopSiteEntity import mozilla.components.feature.top.sites.db.PinnedSiteEntity
internal class TopSiteAdapter( internal class TopSiteAdapter(
internal val entity: TopSiteEntity internal val entity: PinnedSiteEntity
) : TopSite { ) : TopSite {
override val id: Long override val id: Long
get() = entity.id!! get() = entity.id!!
......
...@@ -12,7 +12,7 @@ import androidx.room.PrimaryKey ...@@ -12,7 +12,7 @@ import androidx.room.PrimaryKey
* Internal entity representing a top site. * Internal entity representing a top site.
*/ */
@Entity(tableName = "top_sites") @Entity(tableName = "top_sites")
internal data class TopSiteEntity( internal data class PinnedSiteEntity(
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id") @ColumnInfo(name = "id")
var id: Long? = null, var id: Long? = null,
......
...@@ -13,21 +13,21 @@ import androidx.room.Transaction ...@@ -13,21 +13,21 @@ import androidx.room.Transaction
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
/** /**
* Internal DAO for accessing [TopSiteEntity] instances. * Internal DAO for accessing [PinnedSiteEntity] instances.
*/ */
@Dao @Dao
internal interface TopSiteDao { internal interface TopSiteDao {
@Insert @Insert
fun insertTopSite(site: TopSiteEntity): Long fun insertTopSite(site: PinnedSiteEntity): Long
@Delete @Delete
fun deleteTopSite(site: TopSiteEntity) fun deleteTopSite(site: PinnedSiteEntity)
@Transaction @Transaction
@Query("SELECT * FROM top_sites") @Query("SELECT * FROM top_sites")
fun getTopSites(): Flow<List<TopSiteEntity>> fun getTopSites(): Flow<List<PinnedSiteEntity>>
@Transaction @Transaction
@Query("SELECT * FROM top_sites") @Query("SELECT * FROM top_sites")
fun getTopSitesPaged(): DataSource.Factory<Int, TopSiteEntity> fun getTopSitesPaged(): DataSource.Factory<Int, PinnedSiteEntity>
} }
...@@ -14,7 +14,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase ...@@ -14,7 +14,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
/** /**
* Internal database for storing top sites. * Internal database for storing top sites.
*/ */
@Database(entities = [TopSiteEntity::class], version = 3) @Database(entities = [PinnedSiteEntity::class], version = 3)
internal abstract class TopSiteDatabase : RoomDatabase() { internal abstract class TopSiteDatabase : RoomDatabase() {
abstract fun topSiteDao(): TopSiteDao abstract fun topSiteDao(): TopSiteDao
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment