1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Enhancement/auto refresh (#780)

* Add auto refresh

* Update changelog

* Clean url queries

* Do not discard h
This commit is contained in:
Allan Wang 2018-03-11 21:23:29 -04:00 committed by GitHub
parent fe51373f5a
commit ee4f2eab35
5 changed files with 17 additions and 5 deletions

View File

@ -91,6 +91,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
override var videoViewer: FrostVideoViewer? = null
private lateinit var drawer: Drawer
private lateinit var drawerHeader: AccountHeader
private var lastAccessTime = -1L
override var searchView: SearchView? = null
private val searchViewCache = mutableMapOf<String, List<SearchItem>>()
@ -131,6 +132,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
setupDrawer(savedInstanceState)
L.i { "Main started in ${System.currentTimeMillis() - start} ms" }
initFab()
lastAccessTime = System.currentTimeMillis()
}
/**
@ -301,6 +303,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
private fun refreshAll() {
L.d { "Refresh all" }
fragmentSubject.onNext(REQUEST_REFRESH)
}
@ -403,11 +406,16 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
super.onResume()
FbCookie.switchBackUser {}
controlWebview?.resumeTimers()
if (System.currentTimeMillis() - lastAccessTime > MAIN_TIMEOUT_DURATION) {
refreshAll()
}
lastAccessTime = System.currentTimeMillis() // precaution to avoid loops
}
override fun onPause() {
controlWebview?.pauseTimers()
L.v { "Pause main web timers" }
lastAccessTime = System.currentTimeMillis()
super.onPause()
}

View File

@ -103,7 +103,7 @@ class FbUrlFormatter(url: String) {
val misc = arrayOf("&amp;" to "&")
val discardableQueries = arrayOf("ref", "refid")
val discardableQueries = arrayOf("ref", "refid", "acontext", "SharedWith")
val converter = listOf(
"\\3C " to "%3C", "\\3E " to "%3E", "\\23 " to "%23", "\\25 " to "%25",

View File

@ -117,8 +117,9 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
when (it) {
REQUEST_REFRESH -> {
core?.apply {
reload(true)
clearHistory()
firstLoad = true
firstLoadRequest()
}
}
position -> {

View File

@ -13,4 +13,6 @@ const val REQUEST_RESTART = 1 shl 12
const val REQUEST_REFRESH = 1 shl 13
const val REQUEST_TEXT_ZOOM = 1 shl 14
const val REQUEST_NAV = 1 shl 15
const val REQUEST_SEARCH = 1 shl 16
const val REQUEST_SEARCH = 1 shl 16
const val MAIN_TIMEOUT_DURATION = 30 * 60 * 1000 // 30 min

View File

@ -9,8 +9,9 @@
<version title="v1.8.3" />
<item text="Add full notification channel support" />
<item text="Fix sound spam for multiple notifications" />
<item text="" />
<item text="" />
<item text="Send feedback if no new notifications exist after manual refresh" />
<item text="Automatically refresh if idled for a long time" />
<item text="Clean up url queries" />
<version title="v1.8.2" />
<item text="Fix duplicate notification sounds" />