Skip to content

Commit

Permalink
Merge pull request #2494 from quran/fix_inefficient_lookup
Browse files Browse the repository at this point in the history
Avoid unnecessary reads of translations data
  • Loading branch information
ahmedre authored Dec 10, 2023
2 parents 54cf9f6 + c4993f0 commit 7ff6771
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InlineTranslationPresenter @Inject constructor(
dbAdapter: TranslationsDBAdapter,
translationUtil: TranslationUtil,
private val quranSettings: QuranSettings,
private val translationListPresenter: TranslationListPresenter,
translationListPresenter: TranslationListPresenter,
quranInfo: QuranInfo
) : BaseTranslationPresenter<InlineTranslationPresenter.TranslationScreen>(
translationModel, dbAdapter, translationUtil, quranInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ abstract class AyahActionFragment : Fragment() {
scope = MainScope()
readingEventPresenter.ayahSelectionFlow
.combine(audioEventPresenter.audioPlaybackAyahFlow) { selectedAyah, playbackAyah ->
val (previousStart, previousEnd) = start to end
if (selectedAyah !is AyahSelection.None) {
start = selectedAyah.startSuraAyah()
end = selectedAyah.endSuraAyah()
} else if (playbackAyah != null) {
start = playbackAyah
end = playbackAyah
}
refreshView()

if (previousStart != start || previousEnd != end) {
refreshView()
}
}
.launchIn(scope)

Expand Down

0 comments on commit 7ff6771

Please sign in to comment.