@@ -8,6 +8,7 @@ import com.fredapp.wbooks.data.book.Book
88import com.fredapp.wbooks.data.book.BookFormat
99import com.fredapp.wbooks.data.bookmarks.Bookmark
1010import com.fredapp.wbooks.data.bookmarks.BookmarksRepository
11+ import com.fredapp.wbooks.data.gutenberg.GutenbergDownloadsRepository
1112import com.fredapp.wbooks.data.library.LibraryRepository
1213import com.fredapp.wbooks.data.pace.ReadingPaceRepository
1314import com.fredapp.wbooks.data.position.BookPosition
@@ -82,6 +83,7 @@ class ReaderViewModel(
8283 private val documentCache : DocumentCache ,
8384 private val paceRepo : ReadingPaceRepository ,
8485 private val statsRepo : ReadingStatsRepository ,
86+ private val gutenbergDownloadsRepo : GutenbergDownloadsRepository ,
8587 /* * Application-level scope used for cache writes that must outlive this ViewModel. */
8688 private val appScope : CoroutineScope ,
8789) : ViewModel() {
@@ -142,6 +144,7 @@ class ReaderViewModel(
142144 paceRepo.clear(id)
143145 positionsRepo.clear(id)
144146 bookmarksRepo.clear(id)
147+ gutenbergDownloadsRepo.clear(id)
145148 documentCache.invalidate(id)
146149 }
147150 }
@@ -604,6 +607,7 @@ class ReaderViewModel(
604607 paceRepo.clear(bookId)
605608 positionsRepo.clear(bookId)
606609 bookmarksRepo.clear(bookId)
610+ gutenbergDownloadsRepo.clear(bookId)
607611 documentCache.invalidate(bookId)
608612 }
609613 }
@@ -615,6 +619,7 @@ class ReaderViewModel(
615619 positionsRepo.moveBookId(oldId, newId)
616620 bookmarksRepo.moveBookId(oldId, newId)
617621 statsRepo.moveBookId(oldId, newId)
622+ gutenbergDownloadsRepo.moveBookId(oldId, newId)
618623 documentCache.moveBookId(oldId, newId)
619624 }
620625
@@ -872,14 +877,15 @@ class ReaderViewModel(
872877 private val documentCache : DocumentCache ,
873878 private val paceRepo : ReadingPaceRepository ,
874879 private val statsRepo : ReadingStatsRepository ,
880+ private val gutenbergDownloadsRepo : GutenbergDownloadsRepository ,
875881 private val appScope : CoroutineScope ,
876882 ) : ViewModelProvider.Factory {
877883 @Suppress(" UNCHECKED_CAST" )
878884 override fun <T : ViewModel > create (modelClass : Class <T >): T {
879885 require(modelClass == ReaderViewModel ::class .java)
880886 return ReaderViewModel (
881887 settingsRepo, libraryRepo, positionsRepo, bookmarksRepo, transferController,
882- documentCache, paceRepo, statsRepo, appScope,
888+ documentCache, paceRepo, statsRepo, gutenbergDownloadsRepo, appScope,
883889 ) as T
884890 }
885891 }
0 commit comments