Skip to content

Commit

Permalink
Improved ZimReaderSource creation for previously saved notes/bookmark…
Browse files Browse the repository at this point in the history
…s/history items.
  • Loading branch information
MohitMaliDeveloper committed Feb 8, 2024
1 parent bc64d43 commit 5d69248
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import org.kiwix.kiwixmobile.core.dao.entities.HistoryEntity
import org.kiwix.kiwixmobile.core.dao.entities.HistoryEntity_
import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem.HistoryItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
import java.io.File
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource.Companion.fromDatabaseValue
import javax.inject.Inject

class HistoryDao @Inject constructor(val box: Box<HistoryEntity>) : PageDao {
Expand All @@ -39,7 +38,9 @@ class HistoryDao @Inject constructor(val box: Box<HistoryEntity>) : PageDao {
it.map { historyEntity ->
historyEntity.zimFilePath?.let { filePath ->
// set zimReaderSource for previously saved history items
historyEntity.zimReaderSource = ZimReaderSource.ZimFile(File(filePath))
fromDatabaseValue(filePath)?.let { zimReaderSource ->
historyEntity.zimReaderSource = zimReaderSource
}
}
HistoryItem(historyEntity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import org.kiwix.kiwixmobile.core.dao.entities.BookmarkEntity_
import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.BookmarkItem
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource.ZimFile
import java.io.File
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource.Companion.fromDatabaseValue
import javax.inject.Inject

class NewBookmarksDao @Inject constructor(val box: Box<BookmarkEntity>) : PageDao {
Expand All @@ -40,7 +39,9 @@ class NewBookmarksDao @Inject constructor(val box: Box<BookmarkEntity>) : PageDa
it.map { bookmarkEntity ->
bookmarkEntity.zimFilePath?.let { filePath ->
// set zimReaderSource for previously saved bookmarks
bookmarkEntity.zimReaderSource = ZimFile(File(filePath))
fromDatabaseValue(filePath)?.let { zimReaderSource ->
bookmarkEntity.zimReaderSource = zimReaderSource
}
}
BookmarkItem(bookmarkEntity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity
import org.kiwix.kiwixmobile.core.dao.entities.NotesEntity_
import org.kiwix.kiwixmobile.core.page.adapter.Page
import org.kiwix.kiwixmobile.core.page.notes.adapter.NoteListItem
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource
import java.io.File
import org.kiwix.kiwixmobile.core.reader.ZimReaderSource.Companion.fromDatabaseValue
import javax.inject.Inject

class NewNoteDao @Inject constructor(val box: Box<NotesEntity>) : PageDao {
Expand All @@ -39,7 +38,9 @@ class NewNoteDao @Inject constructor(val box: Box<NotesEntity>) : PageDao {
it.map { notesEntity ->
notesEntity.zimFilePath?.let { filePath ->
// set zimReaderSource for previously saved notes
notesEntity.zimReaderSource = ZimReaderSource.ZimFile(File(filePath))
fromDatabaseValue(filePath)?.let { zimReaderSource ->
notesEntity.zimReaderSource = zimReaderSource
}
}
NoteListItem(notesEntity)
}
Expand Down

0 comments on commit 5d69248

Please sign in to comment.