Move ID into display models & add documentation

This commit is contained in:
Damontecres 2026-01-25 11:08:45 -05:00
parent f58b371698
commit 15ce562957
No known key found for this signature in database
7 changed files with 123 additions and 110 deletions

View file

@ -22,7 +22,6 @@ import java.util.UUID
@Serializable @Serializable
sealed interface HomeRowConfig { sealed interface HomeRowConfig {
val id: Int
val viewOptions: HomeRowViewOptions val viewOptions: HomeRowViewOptions
fun updateViewOptions(viewOptions: HomeRowViewOptions): HomeRowConfig fun updateViewOptions(viewOptions: HomeRowViewOptions): HomeRowConfig
@ -33,7 +32,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("ContinueWatching") @SerialName("ContinueWatching")
data class ContinueWatching( data class ContinueWatching(
override val id: Int,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) : HomeRowConfig { ) : HomeRowConfig {
override fun updateViewOptions(viewOptions: HomeRowViewOptions): ContinueWatching = this.copy(viewOptions = viewOptions) override fun updateViewOptions(viewOptions: HomeRowViewOptions): ContinueWatching = this.copy(viewOptions = viewOptions)
@ -45,7 +43,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("NextUp") @SerialName("NextUp")
data class NextUp( data class NextUp(
override val id: Int,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) : HomeRowConfig { ) : HomeRowConfig {
override fun updateViewOptions(viewOptions: HomeRowViewOptions): NextUp = this.copy(viewOptions = viewOptions) override fun updateViewOptions(viewOptions: HomeRowViewOptions): NextUp = this.copy(viewOptions = viewOptions)
@ -57,7 +54,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("ContinueWatchingCombined") @SerialName("ContinueWatchingCombined")
data class ContinueWatchingCombined( data class ContinueWatchingCombined(
override val id: Int,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) : HomeRowConfig { ) : HomeRowConfig {
override fun updateViewOptions(viewOptions: HomeRowViewOptions): ContinueWatchingCombined = this.copy(viewOptions = viewOptions) override fun updateViewOptions(viewOptions: HomeRowViewOptions): ContinueWatchingCombined = this.copy(viewOptions = viewOptions)
@ -69,7 +65,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("RecentlyAdded") @SerialName("RecentlyAdded")
data class RecentlyAdded( data class RecentlyAdded(
override val id: Int,
val parentId: UUID, val parentId: UUID,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) : HomeRowConfig { ) : HomeRowConfig {
@ -82,7 +77,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("RecentlyReleased") @SerialName("RecentlyReleased")
data class RecentlyReleased( data class RecentlyReleased(
override val id: Int,
val parentId: UUID, val parentId: UUID,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
) : HomeRowConfig { ) : HomeRowConfig {
@ -95,7 +89,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("Genres") @SerialName("Genres")
data class Genres( data class Genres(
override val id: Int,
val parentId: UUID, val parentId: UUID,
override val viewOptions: HomeRowViewOptions = override val viewOptions: HomeRowViewOptions =
HomeRowViewOptions( HomeRowViewOptions(
@ -112,7 +105,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("ByParent") @SerialName("ByParent")
data class ByParent( data class ByParent(
override val id: Int,
val parentId: UUID, val parentId: UUID,
val recursive: Boolean, val recursive: Boolean,
val sort: SortAndDirection? = null, val sort: SortAndDirection? = null,
@ -127,7 +119,6 @@ sealed interface HomeRowConfig {
@Serializable @Serializable
@SerialName("GetItems") @SerialName("GetItems")
data class GetItems( data class GetItems(
override val id: Int,
val name: String, val name: String,
val getItems: GetItemsRequest, val getItems: GetItemsRequest,
override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(), override val viewOptions: HomeRowViewOptions = HomeRowViewOptions(),
@ -136,6 +127,11 @@ sealed interface HomeRowConfig {
} }
} }
/**
* Root class for home page settings
*
* Contains the list of rows and a version
*/
@Serializable @Serializable
@SerialName("HomePageSettings") @SerialName("HomePageSettings")
data class HomePageSettings( data class HomePageSettings(
@ -152,6 +148,11 @@ data class HomePageSettings(
*/ */
const val SUPPORTED_HOME_PAGE_SETTINGS_VERSION = 1 const val SUPPORTED_HOME_PAGE_SETTINGS_VERSION = 1
/**
* View options for displaying a row
*
* Allows for changing things like height or aspect ratio
*/
@Serializable @Serializable
data class HomeRowViewOptions( data class HomeRowViewOptions(
val heightDp: Int = Cards.HEIGHT_2X3_DP, val heightDp: Int = Cards.HEIGHT_2X3_DP,

View file

@ -6,7 +6,6 @@ import com.github.damontecres.wholphin.data.NavDrawerItemRepository
import com.github.damontecres.wholphin.data.model.BaseItem import com.github.damontecres.wholphin.data.model.BaseItem
import com.github.damontecres.wholphin.data.model.HomePageSettings import com.github.damontecres.wholphin.data.model.HomePageSettings
import com.github.damontecres.wholphin.data.model.HomeRowConfig import com.github.damontecres.wholphin.data.model.HomeRowConfig
import com.github.damontecres.wholphin.data.model.HomeRowViewOptions
import com.github.damontecres.wholphin.preferences.HomePagePreferences import com.github.damontecres.wholphin.preferences.HomePagePreferences
import com.github.damontecres.wholphin.ui.DefaultItemFields import com.github.damontecres.wholphin.ui.DefaultItemFields
import com.github.damontecres.wholphin.ui.SlimItemFields import com.github.damontecres.wholphin.ui.SlimItemFields
@ -38,7 +37,6 @@ import org.jellyfin.sdk.model.api.UserDto
import org.jellyfin.sdk.model.api.request.GetGenresRequest import org.jellyfin.sdk.model.api.request.GetGenresRequest
import org.jellyfin.sdk.model.api.request.GetItemsRequest import org.jellyfin.sdk.model.api.request.GetItemsRequest
import org.jellyfin.sdk.model.api.request.GetLatestMediaRequest import org.jellyfin.sdk.model.api.request.GetLatestMediaRequest
import org.jellyfin.sdk.model.serializer.toUUID
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
@ -63,6 +61,11 @@ class HomeSettingsService
val currentSettings = MutableStateFlow(HomePageResolvedSettings.EMPTY) val currentSettings = MutableStateFlow(HomePageResolvedSettings.EMPTY)
/**
* Saves a [HomePageSettings] to the server for the user under the display preference ID
*
* @see loadFromServer
*/
suspend fun saveToServer( suspend fun saveToServer(
userId: UUID, userId: UUID,
settings: HomePageSettings, settings: HomePageSettings,
@ -81,6 +84,13 @@ class HomeSettingsService
) )
} }
/**
* Reads a [HomePageSettings] from the server for the user and display preference ID
*
* Returns null if there is none saved
*
* @see saveToServer
*/
suspend fun loadFromServer( suspend fun loadFromServer(
userId: UUID, userId: UUID,
displayPreferencesId: String = DISPLAY_PREF_ID, displayPreferencesId: String = DISPLAY_PREF_ID,
@ -102,8 +112,16 @@ class HomeSettingsService
client = context.getString(R.string.app_name), client = context.getString(R.string.app_name),
).content ).content
/**
* Computes the filename for locally saved [HomePageSettings]
*/
private fun filename(userId: UUID) = "${CUSTOM_PREF_ID}_${userId.toServerString()}.json" private fun filename(userId: UUID) = "${CUSTOM_PREF_ID}_${userId.toServerString()}.json"
/**
* Save the [HomePageSettings] for the user locally on the device
*
* @see loadFromLocal
*/
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
suspend fun saveToLocal( suspend fun saveToLocal(
userId: UUID, userId: UUID,
@ -116,6 +134,11 @@ class HomeSettingsService
} }
} }
/**
* Reads [HomePageSettings] for the user if it exists
*
* @see saveToLocal
*/
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
suspend fun loadFromLocal(userId: UUID): HomePageSettings? { suspend fun loadFromLocal(userId: UUID): HomePageSettings? {
val dir = File(context.filesDir, CUSTOM_PREF_ID) val dir = File(context.filesDir, CUSTOM_PREF_ID)
@ -129,6 +152,11 @@ class HomeSettingsService
} }
} }
/**
* Decodes [HomePageSettings] from a [JsonElement] skipping any unknown/unparsable rows
*
* This is public only for testing
*/
fun decode(element: JsonElement): HomePageSettings { fun decode(element: JsonElement): HomePageSettings {
val rowsElement = element.jsonObject["rows"]?.jsonArray val rowsElement = element.jsonObject["rows"]?.jsonArray
val rows = val rows =
@ -145,7 +173,14 @@ class HomeSettingsService
return HomePageSettings(rows) return HomePageSettings(rows)
} }
suspend fun updateCurrent(userId: UUID) { /**
* Loads [HomePageSettings] into [currentSettings]
*
* First checks locally, then on the server, and finally creates a default if needed
*
* Does not persist either the server nor default
*/
suspend fun loadCurrentSettings(userId: UUID) {
Timber.v("Getting setting for %s", userId) Timber.v("Getting setting for %s", userId)
// User local then server/remote otherwise create a default // User local then server/remote otherwise create a default
val settings = loadFromLocal(userId) ?: loadFromServer(userId) val settings = loadFromLocal(userId) ?: loadFromServer(userId)
@ -153,7 +188,10 @@ class HomeSettingsService
if (settings != null) { if (settings != null) {
Timber.v("Found settings") Timber.v("Found settings")
// Resolve // Resolve
val resolvedRows = settings.rows.map { convert(it) } val resolvedRows =
settings.rows.mapIndexed { index, config ->
resolve(index, config)
}
HomePageResolvedSettings(resolvedRows) HomePageResolvedSettings(resolvedRows)
} else { } else {
createDefault(userId) createDefault(userId)
@ -162,7 +200,10 @@ class HomeSettingsService
currentSettings.update { resolvedSettings } currentSettings.update { resolvedSettings }
} }
suspend fun createDefault(userId: UUID): HomePageResolvedSettings { /**
* Create a default [HomePageResolvedSettings] using the available libraries
*/
private suspend fun createDefault(userId: UUID): HomePageResolvedSettings {
Timber.v("Creating default settings") Timber.v("Creating default settings")
val navDrawerItems = navDrawerItemRepository.getNavDrawerItems() val navDrawerItems = navDrawerItemRepository.getNavDrawerItems()
val libraries = val libraries =
@ -179,76 +220,51 @@ class HomeSettingsService
.getFilteredNavDrawerItems(navDrawerItems) .getFilteredNavDrawerItems(navDrawerItems)
.filter { it is ServerNavDrawerItem } .filter { it is ServerNavDrawerItem }
.mapIndexed { index, it -> .mapIndexed { index, it ->
val id = (it as ServerNavDrawerItem).itemId val parentId = (it as ServerNavDrawerItem).itemId
val name = libraries.firstOrNull { it.itemId == id }?.name val name = libraries.firstOrNull { it.itemId == parentId }?.name
val title = val title =
name?.let { context.getString(R.string.recently_added_in, it) } name?.let { context.getString(R.string.recently_added_in, it) }
?: context.getString(R.string.recently_added) ?: context.getString(R.string.recently_added)
HomeRowConfigDisplay( HomeRowConfigDisplay(
title, id = index,
HomeRowConfig.RecentlyAdded( title = title,
index, config = HomeRowConfig.RecentlyAdded(parentId),
id,
HomeRowViewOptions(),
),
) )
} }
val continueWatchingRows = val continueWatchingRows =
if (prefs.combineContinueNext) { if (prefs.combineContinueNext) { // TODO
listOf( listOf(
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.combine_continue_next), id = includedIds.size + 1,
HomeRowConfig.ContinueWatchingCombined( title = context.getString(R.string.combine_continue_next),
includedIds.size + 1, config = HomeRowConfig.ContinueWatchingCombined(),
HomeRowViewOptions(),
),
), ),
) )
} else { } else {
listOf( listOf(
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.continue_watching), id = includedIds.size + 1,
HomeRowConfig.ContinueWatching( title = context.getString(R.string.continue_watching),
includedIds.size + 1, config = HomeRowConfig.ContinueWatching(),
HomeRowViewOptions(),
),
), ),
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.next_up), id = includedIds.size + 2,
HomeRowConfig.NextUp( title = context.getString(R.string.next_up),
includedIds.size + 2, config = HomeRowConfig.NextUp(),
HomeRowViewOptions(),
),
), ),
) )
} }
val rowConfig = val rowConfig = continueWatchingRows + includedIds
continueWatchingRows + includedIds +
// TODO remove after testing
listOf(
HomeRowConfigDisplay(
"Collection",
HomeRowConfig.ByParent(
id = 100,
parentId = "34ab6fd1f51c41bb014981f2e334f465".toUUID(),
recursive = true,
viewOptions = HomeRowViewOptions(),
),
),
HomeRowConfigDisplay(
"Playlist",
HomeRowConfig.ByParent(
id = 101,
parentId = "f94be36e9836127a0bccfc7843b19e5b".toUUID(),
recursive = true,
viewOptions = HomeRowViewOptions(),
),
),
)
return HomePageResolvedSettings(rowConfig) return HomePageResolvedSettings(rowConfig)
} }
suspend fun convert(config: HomeRowConfig): HomeRowConfigDisplay = /**
* Converts a [HomeRowConfig] into [HomeRowConfigDisplay] for UI purposes
*/
private suspend fun resolve(
id: Int,
config: HomeRowConfig,
): HomeRowConfigDisplay =
when (config) { when (config) {
is HomeRowConfig.ByParent -> { is HomeRowConfig.ByParent -> {
val name = val name =
@ -256,6 +272,7 @@ class HomeSettingsService
.getItem(itemId = config.parentId) .getItem(itemId = config.parentId)
.content.name ?: "" .content.name ?: ""
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
name, name,
config, config,
) )
@ -263,6 +280,7 @@ class HomeSettingsService
is HomeRowConfig.ContinueWatching -> { is HomeRowConfig.ContinueWatching -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.continue_watching), context.getString(R.string.continue_watching),
config, config,
) )
@ -270,6 +288,7 @@ class HomeSettingsService
is HomeRowConfig.ContinueWatchingCombined -> { is HomeRowConfig.ContinueWatchingCombined -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.combine_continue_next), context.getString(R.string.combine_continue_next),
config, config,
) )
@ -281,17 +300,19 @@ class HomeSettingsService
.getItem(itemId = config.parentId) .getItem(itemId = config.parentId)
.content.name ?: "" .content.name ?: ""
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.genres_in, name), context.getString(R.string.genres_in, name),
config, config,
) )
} }
is HomeRowConfig.GetItems -> { is HomeRowConfig.GetItems -> {
HomeRowConfigDisplay(config.name, config) HomeRowConfigDisplay(id, config.name, config)
} }
is HomeRowConfig.NextUp -> { is HomeRowConfig.NextUp -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.next_up), context.getString(R.string.next_up),
config, config,
) )
@ -303,6 +324,7 @@ class HomeSettingsService
.getItem(itemId = config.parentId) .getItem(itemId = config.parentId)
.content.name ?: "" .content.name ?: ""
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.recently_added_in, name), context.getString(R.string.recently_added_in, name),
config, config,
) )
@ -314,12 +336,16 @@ class HomeSettingsService
.getItem(itemId = config.parentId) .getItem(itemId = config.parentId)
.content.name ?: "" .content.name ?: ""
HomeRowConfigDisplay( HomeRowConfigDisplay(
id,
context.getString(R.string.recently_released_in, name), context.getString(R.string.recently_released_in, name),
config, config,
) )
} }
} }
/**
* Fetch the data from the server for a given [HomeRowConfig]
*/
suspend fun fetchDataForRow( suspend fun fetchDataForRow(
row: HomeRowConfig, row: HomeRowConfig,
scope: CoroutineScope, scope: CoroutineScope,
@ -553,11 +579,20 @@ class HomeSettingsService
} }
} }
/**
* A [HomeRowConfig] with a resolved ID and title so it is usable in the UI
*/
data class HomeRowConfigDisplay( data class HomeRowConfigDisplay(
val id: Int,
val title: String, val title: String,
val config: HomeRowConfig, val config: HomeRowConfig,
) )
/**
* List of resolved [HomeRowConfig]s as [HomeRowConfigDisplay]s
*
* @see HomePageSettings
*/
data class HomePageResolvedSettings( data class HomePageResolvedSettings(
val rows: List<HomeRowConfigDisplay>, val rows: List<HomeRowConfigDisplay>,
) { ) {

View file

@ -225,7 +225,7 @@ class UserSwitchListener
if (user != null) { if (user != null) {
// Check for home settings // Check for home settings
launchIO { launchIO {
homeSettingsService.updateCurrent(user.id) homeSettingsService.loadCurrentSettings(user.id)
} }
// Check for seerr server // Check for seerr server
launchIO { launchIO {

View file

@ -72,7 +72,7 @@ fun HomeSettingsPage(
onClickMove = viewModel::moveRow, onClickMove = viewModel::moveRow,
onClickDelete = viewModel::deleteRow, onClickDelete = viewModel::deleteRow,
onClick = { index, row -> onClick = { index, row ->
destination = HomeSettingsDestination.RowSettings(row.config.id) destination = HomeSettingsDestination.RowSettings(row.id)
scope.launch(ExceptionHandler()) { scope.launch(ExceptionHandler()) {
Timber.v("Scroll to $index") Timber.v("Scroll to $index")
listState.scrollToItem(index) listState.scrollToItem(index)
@ -108,7 +108,7 @@ fun HomeSettingsPage(
is HomeSettingsDestination.RowSettings -> { is HomeSettingsDestination.RowSettings -> {
val row = val row =
state.rows state.rows
.first { it.config.id == dest.rowId } .first { it.id == dest.rowId }
HomeRowSettings( HomeRowSettings(
title = row.title, title = row.title,
viewOptions = row.config.viewOptions, viewOptions = row.config.viewOptions,

View file

@ -103,7 +103,7 @@ fun HomeSettingsRowList(
item { item {
HorizontalDivider() HorizontalDivider()
} }
itemsIndexed(state.rows, key = { _, row -> row.config.id }) { index, row -> itemsIndexed(state.rows, key = { _, row -> row.id }) { index, row ->
HomeRowConfigContent( HomeRowConfigContent(
config = row, config = row,
moveUpAllowed = index > 0, moveUpAllowed = index > 0,

View file

@ -162,31 +162,25 @@ class HomeSettingsViewModel
when (type) { when (type) {
MetaRowType.CONTINUE_WATCHING -> { MetaRowType.CONTINUE_WATCHING -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.continue_watching), id = id,
HomeRowConfig.ContinueWatching( title = context.getString(R.string.continue_watching),
id, config = HomeRowConfig.ContinueWatching(),
HomeRowViewOptions(),
),
) )
} }
MetaRowType.NEXT_UP -> { MetaRowType.NEXT_UP -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.continue_watching), id = id,
HomeRowConfig.NextUp( title = context.getString(R.string.continue_watching),
id, config = HomeRowConfig.NextUp(),
HomeRowViewOptions(),
),
) )
} }
MetaRowType.COMBINED_CONTINUE_WATCHING -> { MetaRowType.COMBINED_CONTINUE_WATCHING -> {
HomeRowConfigDisplay( HomeRowConfigDisplay(
context.getString(R.string.combine_continue_next), id = id,
HomeRowConfig.ContinueWatchingCombined( title = context.getString(R.string.combine_continue_next),
id, config = HomeRowConfig.ContinueWatchingCombined(),
HomeRowViewOptions(),
),
) )
} }
} }
@ -212,12 +206,9 @@ class HomeSettingsViewModel
val title = val title =
library.name.let { context.getString(R.string.recently_added_in, it) } library.name.let { context.getString(R.string.recently_added_in, it) }
HomeRowConfigDisplay( HomeRowConfigDisplay(
title, id = id,
HomeRowConfig.RecentlyAdded( title = title,
id, config = HomeRowConfig.RecentlyAdded(library.itemId),
library.itemId,
HomeRowViewOptions(),
),
) )
} }
@ -230,23 +221,18 @@ class HomeSettingsViewModel
) )
} }
HomeRowConfigDisplay( HomeRowConfigDisplay(
title, id = id,
HomeRowConfig.RecentlyReleased( title = title,
id, config = HomeRowConfig.RecentlyReleased(library.itemId),
library.itemId,
HomeRowViewOptions(),
),
) )
} }
LibraryRowType.GENRES -> { LibraryRowType.GENRES -> {
val title = library.name.let { context.getString(R.string.genres_in, it) } val title = library.name.let { context.getString(R.string.genres_in, it) }
HomeRowConfigDisplay( HomeRowConfigDisplay(
title, id = id,
HomeRowConfig.Genres( title = title,
id, config = HomeRowConfig.Genres(library.itemId),
library.itemId,
),
) )
} }
} }
@ -266,7 +252,7 @@ class HomeSettingsViewModel
) { ) {
viewModelScope.launchIO { viewModelScope.launchIO {
updateState { updateState {
val index = it.rows.indexOfFirst { it.config.id == rowId } val index = it.rows.indexOfFirst { it.id == rowId }
val newRowConfig = val newRowConfig =
it.rows[index] it.rows[index]
.config .config

View file

@ -23,7 +23,6 @@ class TestHomeRowSamples {
val SAMPLES = val SAMPLES =
listOf( listOf(
HomeRowConfig.RecentlyAdded( HomeRowConfig.RecentlyAdded(
id = 0,
parentId = UUID.randomUUID(), parentId = UUID.randomUUID(),
viewOptions = viewOptions =
HomeRowViewOptions( HomeRowViewOptions(
@ -37,36 +36,29 @@ class TestHomeRowSamples {
), ),
), ),
HomeRowConfig.RecentlyReleased( HomeRowConfig.RecentlyReleased(
id = 0,
parentId = UUID.randomUUID(), parentId = UUID.randomUUID(),
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.Genres( HomeRowConfig.Genres(
id = 0,
parentId = UUID.randomUUID(), parentId = UUID.randomUUID(),
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.ContinueWatching( HomeRowConfig.ContinueWatching(
id = 0,
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.NextUp( HomeRowConfig.NextUp(
id = 0,
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.ContinueWatchingCombined( HomeRowConfig.ContinueWatchingCombined(
id = 0,
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.ByParent( HomeRowConfig.ByParent(
id = 0,
parentId = UUID.randomUUID(), parentId = UUID.randomUUID(),
recursive = true, recursive = true,
sort = SortAndDirection(ItemSortBy.CRITIC_RATING, SortOrder.ASCENDING), sort = SortAndDirection(ItemSortBy.CRITIC_RATING, SortOrder.ASCENDING),
viewOptions = HomeRowViewOptions(), viewOptions = HomeRowViewOptions(),
), ),
HomeRowConfig.GetItems( HomeRowConfig.GetItems(
id = 0,
name = "Episodes by date created", name = "Episodes by date created",
getItems = getItems =
GetItemsRequest( GetItemsRequest(
@ -116,7 +108,7 @@ class TestHomeRowSamples {
} }
@Test @Test
fun test() { fun `Parse list of rows with an unknown type`() {
val service = val service =
HomeSettingsService( HomeSettingsService(
context = mockk(), context = mockk(),
@ -133,7 +125,6 @@ class TestHomeRowSamples {
"rows": [ "rows": [
{ {
"type": "RecentlyAdded", "type": "RecentlyAdded",
"id": 0,
"parentId": "1dd1c2fd-2e1b-48e4-ba94-17a2350fe9cf" "parentId": "1dd1c2fd-2e1b-48e4-ba94-17a2350fe9cf"
}, },
{ {