Skip to content

Commit

Permalink
Fixed adding books to library while importing the bookmarks. Also imp…
Browse files Browse the repository at this point in the history
…roved the convertor of room and objectbox
  • Loading branch information
MohitMaliDeveloper committed Aug 24, 2024
1 parent 58cbd5d commit 31991bd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class LibkiwixBookmarks @Inject constructor(
}
// Add the ZIM files to the library for validating the bookmarks.
bookDao.getBooks().forEach {
addBookToLibrary(file = it.file)
addBookToLibrary(file = it.zimReaderSource.file)
}
// Save the imported bookmarks to the current library.
tempLibrary.getBookmarks(false)?.toList()?.forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ data class BookOnDiskEntity(
}

class ZimSourceConverter : PropertyConverter<ZimReaderSource, String> {
override fun convertToDatabaseValue(entityProperty: ZimReaderSource?) =
override fun convertToDatabaseValue(entityProperty: ZimReaderSource?): String =
entityProperty?.toDatabase() ?: ""

override fun convertToEntityProperty(databaseValue: String?): ZimReaderSource =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ package org.kiwix.kiwixmobile.core.dao.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import io.objectbox.annotation.Convert
import io.objectbox.converter.PropertyConverter
import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem.HistoryItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
import java.io.File

@Entity
@TypeConverters(ZimSourceRoomConverter::class)
data class HistoryRoomEntity(
@PrimaryKey(autoGenerate = true) var id: Long = 0L,
val zimId: String,
Expand Down Expand Up @@ -58,7 +54,7 @@ data class HistoryRoomEntity(

class ZimSourceRoomConverter {
@TypeConverter
fun convertToDatabaseValue(entityProperty: ZimReaderSource?) =
fun convertToDatabaseValue(entityProperty: ZimReaderSource?): String =
entityProperty?.toDatabase() ?: ""

@TypeConverter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.core.dao.entities
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import io.objectbox.annotation.Convert
import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource

Expand All @@ -31,7 +30,6 @@ data class NotesRoomEntity(
var id: Long = 0L,
val zimId: String,
var zimFilePath: String?, // keep this to handle previously saved notes
@Convert(converter = ZimSourceConverter::class, dbType = String::class)
var zimReaderSource: ZimReaderSource?,
val zimUrl: String,
var noteTitle: String,
Expand Down

0 comments on commit 31991bd

Please sign in to comment.