diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index 04e76d3bd..bae53c8f2 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -9,13 +9,13 @@ import io.legado.app.data.entities.Book @Dao interface BookDao { - @Query("SELECT * FROM books") + @Query("SELECT * FROM books order by durChapterTime desc") fun observeAll(): DataSource.Factory - @Query("SELECT * FROM books WHERE type = ${BookType.audio}") + @Query("SELECT * FROM books WHERE type = ${BookType.audio} order by durChapterTime desc") fun observeAudio(): DataSource.Factory - @Query("SELECT * FROM books WHERE origin = '${BookType.local}'") + @Query("SELECT * FROM books WHERE origin = '${BookType.local}' order by durChapterTime desc") fun observeLocal(): DataSource.Factory @Query("SELECT * FROM books WHERE `group` = :group") @@ -42,12 +42,6 @@ interface BookDao { @get:Query("SELECT COUNT(*) FROM books") val allBookCount: Int - @Query("SELECT * FROM books ORDER BY durChapterTime DESC limit 0,20") - fun recentRead(): DataSource.Factory - - @Query("SELECT * FROM books ORDER BY durChapterTime DESC limit 0,20") - fun getRecentRead(): List - @Insert(onConflict = OnConflictStrategy.REPLACE) fun insert(vararg book: Book) @@ -56,4 +50,5 @@ interface BookDao { @Query("delete from books where bookUrl = :bookUrl") fun delete(bookUrl: String) + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index 9f191510a..3a9c1db32 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -23,7 +23,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) { fun upChapterList() { execute { - App.db.bookDao().getRecentRead().forEach { book -> + App.db.bookDao().allBooks.forEach { book -> if (book.origin != BookType.local) { App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> synchronized(this) {