musikr: add date added support w/cache
This allows me to replicate something resembling date added support while reducing query load.
This commit is contained in:
@@ -27,6 +27,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
import org.oxycblt.musikr.cache.Cache
|
||||
import org.oxycblt.musikr.cache.StoredCache
|
||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||
|
||||
@Module
|
||||
@@ -40,7 +41,7 @@ interface MusicModule {
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
class MusikrShimModule {
|
||||
@Singleton @Provides fun cache(@ApplicationContext context: Context) = Cache.from(context)
|
||||
@Singleton @Provides fun storedCache(@ApplicationContext context: Context) = StoredCache.from(context)
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
|
||||
@@ -37,8 +37,7 @@ import org.oxycblt.musikr.MutableLibrary
|
||||
import org.oxycblt.musikr.Playlist
|
||||
import org.oxycblt.musikr.Song
|
||||
import org.oxycblt.musikr.Storage
|
||||
import org.oxycblt.musikr.cache.Cache
|
||||
import org.oxycblt.musikr.cache.WriteOnlyCache
|
||||
import org.oxycblt.musikr.cache.StoredCache
|
||||
import org.oxycblt.musikr.playlist.db.StoredPlaylists
|
||||
import org.oxycblt.musikr.tag.interpret.Naming
|
||||
import org.oxycblt.musikr.tag.interpret.Separators
|
||||
@@ -214,7 +213,7 @@ class MusicRepositoryImpl
|
||||
@Inject
|
||||
constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val cache: Cache,
|
||||
private val storedCache: StoredCache,
|
||||
private val storedPlaylists: StoredPlaylists,
|
||||
private val musicSettings: MusicSettings
|
||||
) : MusicRepository {
|
||||
@@ -363,7 +362,7 @@ constructor(
|
||||
|
||||
val currentRevision = musicSettings.revision
|
||||
val newRevision = currentRevision?.takeIf { withCache } ?: UUID.randomUUID()
|
||||
val cache = if (withCache) cache else WriteOnlyCache(cache)
|
||||
val cache = if (withCache) storedCache.full() else storedCache.writeOnly()
|
||||
val covers = MutableRevisionedStoredCovers(context, newRevision)
|
||||
val storage = Storage(cache, covers, storedPlaylists)
|
||||
val interpretation = Interpretation(nameFactory, separators)
|
||||
|
||||
Reference in New Issue
Block a user