Store remembered tabs in app database instead of preferences (#1541)

## Description
Moves storing the remembered tabs from app preferences to the app
database. This means deleting the user will remove the remembered tabs
and the app preferences file is smaller and faster to load.

The remembered tabs are migrated automatically when the app is updated.

There are no significant user facing changes in this PR.

### Related issues
N/A

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-06-08 13:45:38 -04:00 • committed by GitHub
parent a4ee1e5175
commit b49926f80b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1379 additions and 599 deletions

View file

@ -16,6 +16,7 @@ import com.github.damontecres.wholphin.data.model.LibraryDisplayInfo
import com.github.damontecres.wholphin.data.model.NavDrawerPinnedItem
import com.github.damontecres.wholphin.data.model.PlaybackEffect
import com.github.damontecres.wholphin.data.model.PlaybackLanguageChoice
import com.github.damontecres.wholphin.data.model.RememberedTab
import com.github.damontecres.wholphin.data.model.SeerrServer
import com.github.damontecres.wholphin.data.model.SeerrUser
import com.github.damontecres.wholphin.ui.components.ViewOptions
@ -46,8 +47,9 @@ import java.util.UUID
ItemTrackModification::class,
SeerrServer::class,
SeerrUser::class,
RememberedTab::class,
],
version = 33,
version = 34,
exportSchema = true,
autoMigrations = [
AutoMigration(3, 4),
@ -64,6 +66,7 @@ import java.util.UUID
AutoMigration(30, 31),
AutoMigration(31, 32),
AutoMigration(32, 33),
AutoMigration(33, 34),
],
)
@TypeConverters(Converters::class)
@ -81,6 +84,8 @@ abstract class AppDatabase : RoomDatabase() {
abstract fun seerrServerDao(): SeerrServerDao
abstract fun playbackEffectDao(): PlaybackEffectDao
abstract fun rememberedTabDao(): RememberedTabDao
}
class Converters {

View file

@ -0,0 +1,22 @@
package com.github.damontecres.wholphin.data
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.github.damontecres.wholphin.data.model.RememberedTab
@Dao
interface RememberedTabDao {
@Query("SELECT * from RememberedTab WHERE userId=:userId AND itemId=:itemId")
suspend fun getRememberedTab(
userId: Int,
itemId: String,
): RememberedTab?
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun save(item: RememberedTab): Long
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun saveAll(items: List<RememberedTab>)
}

View file

@ -0,0 +1,24 @@
package com.github.damontecres.wholphin.data.model
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
@Entity(
foreignKeys = [
ForeignKey(
entity = JellyfinUser::class,
parentColumns = arrayOf("rowId"),
childColumns = arrayOf("userId"),
onDelete = ForeignKey.CASCADE,
onUpdate = ForeignKey.CASCADE,
),
],
indices = [Index("userId", "itemId", unique = true)],
primaryKeys = ["userId", "itemId"],
)
data class RememberedTab(
val userId: Int,
val itemId: String,
val index: Int,
)