2-Migrate-Persistence-Layer-from-JSON-Files-to-Room-Database #4
@@ -2,6 +2,7 @@ package dev.dettmer.simplenotes.di
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import dev.dettmer.simplenotes.MainViewModel
|
||||
import dev.dettmer.simplenotes.storage.AppDatabase
|
||||
import dev.dettmer.simplenotes.storage.NotesStorage
|
||||
import dev.dettmer.simplenotes.ui.main.MainViewModel
|
||||
@@ -29,5 +30,5 @@ val appModule = module {
|
||||
|
||||
single { NotesStorage(androidContext(), get()) }
|
||||
|
||||
viewModel { MainViewModel(get(), get()) }
|
||||
viewModel { MainViewModel(get(), get(), get()) }
|
||||
}
|
||||
|
||||
@@ -211,7 +211,8 @@ class MainViewModel(
|
||||
val pendingIds = _pendingDeletions.value
|
||||
val filteredNotes = allNotes.filter { it.id !in pendingIds }.map { Note(
|
||||
id = it.id,
|
||||
content = it.content
|
||||
content = it.content,
|
||||
|
||||
) }
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
|
||||
Reference in New Issue
Block a user