mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
阅读记录添加最后阅读时间
This commit is contained in:
1674
app/schemas/io.legado.app.data.AppDatabase/51.json
Normal file
1674
app/schemas/io.legado.app.data.AppDatabase/51.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ val appDb by lazy {
|
||||
}
|
||||
|
||||
@Database(
|
||||
version = 50,
|
||||
version = 51,
|
||||
exportSchema = true,
|
||||
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
||||
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
||||
@@ -34,7 +34,8 @@ val appDb by lazy {
|
||||
AutoMigration(from = 46, to = 47),
|
||||
AutoMigration(from = 47, to = 48),
|
||||
AutoMigration(from = 48, to = 49),
|
||||
AutoMigration(from = 49, to = 50)
|
||||
AutoMigration(from = 49, to = 50),
|
||||
AutoMigration(from = 50, to = 51)
|
||||
]
|
||||
)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package io.legado.app.data.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
|
||||
@Entity(tableName = "readRecord", primaryKeys = ["deviceId", "bookName"])
|
||||
data class ReadRecord(
|
||||
var deviceId: String = "",
|
||||
var bookName: String = "",
|
||||
var readTime: Long = 0L
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
var readTime: Long = 0L,
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
var lastRead: Long = System.currentTimeMillis()
|
||||
)
|
||||
@@ -117,6 +117,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
Coroutine.async {
|
||||
readRecord.readTime = readRecord.readTime + System.currentTimeMillis() - readStartTime
|
||||
readStartTime = System.currentTimeMillis()
|
||||
readRecord.lastRead = System.currentTimeMillis()
|
||||
if (AppConfig.enableReadRecord) {
|
||||
appDb.readRecordDao.insert(readRecord)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user