Prep inMemory database
This commit is contained in:
@@ -15,4 +15,10 @@ actual object PlatformDatabaseBuilder {
|
||||
name = dbFile.absolutePath
|
||||
)
|
||||
}
|
||||
|
||||
actual fun getInMemoryDatabaseBuilder(platform: PlatformContext): RoomDatabase.Builder<AuxDatabase> {
|
||||
return Room.inMemoryDatabaseBuilder(
|
||||
context = platform.applicationContext
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import kotlinx.coroutines.IO
|
||||
|
||||
expect object PlatformDatabaseBuilder {
|
||||
fun getDatabaseBuilder(platformContext: PlatformContext): RoomDatabase.Builder<AuxDatabase>
|
||||
|
||||
fun getInMemoryDatabaseBuilder(platform: PlatformContext): RoomDatabase.Builder<AuxDatabase>
|
||||
}
|
||||
|
||||
fun getRoomDatabase(
|
||||
|
||||
@@ -4,6 +4,7 @@ import ac.aux.compose.AuxGlobal
|
||||
import ac.aux.compose.database.AuxDatabaseConstructor
|
||||
import ac.aux.compose.database.builder.PlatformDatabaseBuilder
|
||||
import ac.aux.compose.database.builder.getRoomDatabase
|
||||
import androidx.room.Room
|
||||
|
||||
class DatabaseManager(
|
||||
auxGlobal: AuxGlobal
|
||||
@@ -15,4 +16,17 @@ class DatabaseManager(
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic data like user feeds and the likes will be in a in-memory db.
|
||||
*
|
||||
* We may also decide to just use the normal DB and manage what's saved better...
|
||||
*/
|
||||
val inMemoryAuxDatabase by lazy {
|
||||
getRoomDatabase(
|
||||
PlatformDatabaseBuilder.getInMemoryDatabaseBuilder(
|
||||
auxGlobal.platformContext
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,6 @@ fun FeedScreen(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
stickyHeader {
|
||||
|
||||
Surface() {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().padding(10.dp)
|
||||
|
||||
@@ -68,6 +68,9 @@ fun AuxNavHost(
|
||||
val nostrRepository = DatabaseNostrRepository(
|
||||
database = databaseManager.auxDatabase
|
||||
)
|
||||
val inMemoryNostrRepository = DatabaseNostrRepository(
|
||||
database = databaseManager.inMemoryAuxDatabase
|
||||
)
|
||||
|
||||
val exceptionHandler =
|
||||
CoroutineExceptionHandler { _, throwable ->
|
||||
|
||||
@@ -29,4 +29,8 @@ actual object PlatformDatabaseBuilder {
|
||||
return requireNotNull(documentDirectory?.path)
|
||||
}
|
||||
|
||||
actual fun getInMemoryDatabaseBuilder(platform: PlatformContext): RoomDatabase.Builder<AuxDatabase> {
|
||||
return Room.inMemoryDatabaseBuilder()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,4 +13,8 @@ actual object PlatformDatabaseBuilder {
|
||||
name = dbFile.absolutePath,
|
||||
)
|
||||
}
|
||||
|
||||
actual fun getInMemoryDatabaseBuilder(platform: PlatformContext): RoomDatabase.Builder<AuxDatabase> {
|
||||
return Room.inMemoryDatabaseBuilder()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user