Commit 09aea0f7 authored by Christophe Henry's avatar Christophe Henry
Browse files

Fix #95: App sometimes crash when closing article

parent 9e289b5e
Pipeline #4172 passed with stage
in 0 seconds
# Development
# Bug fixes
## Bug fixes
* Fix [#95](https://git.feneas.org/christophehenry/freshrss-android/-/issues/95): App sometimes crash when closing article ([!97](https://git.feneas.org/christophehenry/freshrss-android/-/merge_requests/97))
* Fix [#96](https://git.feneas.org/christophehenry/freshrss-android/-/issues/96): app crashes when trying to login to a bad URL ([!98](https://git.feneas.org/christophehenry/freshrss-android/-/merge_requests/98))
* Fix [#98](https://git.feneas.org/christophehenry/freshrss-android/-/issues/98): automatically refresh if needed on activity resume ([!100](https://git.feneas.org/christophehenry/freshrss-android/merge_requests/100))
* Fix [#94](https://git.feneas.org/christophehenry/freshrss-android/-/issues/94): refresh fails when feed icon contains errors ([!102](https://git.feneas.org/christophehenry/freshrss-android/-/merge_requests/102))
......
......@@ -107,10 +107,15 @@ open class FreshRSSApplication: Application(), SharedPreferences.OnSharedPrefere
}.unit()
open fun ensurePeriodicRequest() = GlobalScope.launch {
if(!isPeriodicRefreshEnabled() || workManager.getPeriodicRefreshWorks().isNotEmpty()) return@launch
if(!isPeriodicRefreshEnabled()) return@launch
val period = Store.account.value?.lastFetchDate?.let {Period(it, DateTime.now())}
val initialDelay = preferences.refreshFrequency - (period?.minutes?.toLong() ?: preferences.refreshFrequency)
enqueuePeriodicWork(max(0, initialDelay))
if(
workManager.getPeriodicRefreshWorks().isEmpty() ||
initialDelay <= 0 && workManager.getPeriodicRefreshWorks().isNotEmpty()
) enqueuePeriodicWork(max(0, initialDelay))
}
fun isPeriodicRefreshEnabled() = preferences.refreshFrequency > 0
......
......@@ -79,8 +79,11 @@ class ArticleDetailFragment: Fragment(), View.OnClickListener {
override fun onDestroyView() {
supportActionBar?.subtitle = null
val scrollPosition = fragment_subscription_article_detail_web_view.scrollY
// database will be updated asynchronously. So we need to retrieve pointer on the DB before
// the fragment is disconnected from the activity
val database = requireF().db
GlobalScope.launch {
requireF().db.updateArticleScrollPosition(article.id, scrollPosition)
database.updateArticleScrollPosition(article.id, scrollPosition)
}
super.onDestroyView()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment