Skip to content

Conversation

@stevenzeck
Copy link
Contributor

@stevenzeck stevenzeck commented Dec 14, 2021

I started out just updating dependencies, but decided to fix some of the issues with unit tests and json.

  • Updated Kotlin from 1.5.31 to 1.6.10
  • Updated Gradle from 7.0.3 to 7.0.4
  • Updated all dependencies in all modules. This required modifying some of the code to fix breaking changes, but should not affect functionality
  • Using the org.json:json library for mocking JSONObject and the like in the tests was not working on newer versions. As it is already using org.robolectric:robolectric I annotated each relevant file with @RunWith(RobolectricTestRunner::class)
  • Removed the jackson dependencies and deleted the MediaOverlayHandler class
  • Added an index in the Highlight table for BOOK_ID, as that warning has been there for several months
  • Cleaned up test dependencies, removing unused ones and migrating some assertion calls from one framework to another

foreignKeys = [
ForeignKey(entity = Book::class, parentColumns = [Book.ID], childColumns = [Highlight.BOOK_ID], onDelete = ForeignKey.CASCADE)
],
indices = [Index(value = [Highlight.BOOK_ID])]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely spotted ;)

Comment on lines 142 to 144
else -> {
Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will show the toast when the user start a search in a book. I think instead we should simply add branches for all the available events.

Currently the SearchFragment is handling the StartNewSearch event which is dangerous as if we revert to a single Channel for event handling, it can by default have only a single observer. Best practice would be to handle all the events in the ReaderActivity, and forward downward any event if needed.

For this PR, I suggest we just move the StartNewSearch event to the ReaderViewModel.FeedbackEvent enum and let the EpubReaderFragment take ownership of this event handling, as it has access to the SearchFragment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EpubReaderFragment doesn't have a reference to SearchFragment, all it does show the fragment via the fragment manager, so it's not quite as easy as letting EpubReaderFragment take ownership of event handling for this. But yeah that's an overlook on my part putting a toast error message when it results in showing that when a new search begins. I think the best thing to do is just add an empty else branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good for now, we can always fix this in a dedicated refactoring.

@mickael-menu mickael-menu merged commit ffea0b4 into readium:develop Dec 19, 2021
@mickael-menu mickael-menu deleted the update-dependencies branch December 19, 2021 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants