From 86df98094d202701690d597024558ccaa6d41abd Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 29 Dec 2019 21:54:15 -0800 Subject: Fix townhall loading (#1603) * Fix townhall loading * Clean up logs * Remove extra imports * Optimize imports * Fix query test --- .../com/pitchedapps/frost/fragments/WebFragments.kt | 16 ++++++++++++++++ app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 6 +++++- .../kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt index 0a3884ff..a6b4eae7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt @@ -60,4 +60,20 @@ class WebFragment : BaseFragment() { } super.updateFab(contract) } + + override fun onBackPressed(): Boolean { + if (baseEnum == FbItem.MENU) { + val core = core + val web = core as? WebView + if (web != null && web.canGoBack() && !web.canGoBackOrForward(-2)) { + // If menu item + we are at the second last entry, reload the base + // To properly inflate the menu + // Related to https://github.com/AllanWang/Frost-for-Facebook/issues/1593 + core.clearHistory() + core.reloadBase(true) + return true + } + } + return super.onBackPressed() + } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 8c5f6db6..2060cf12 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -352,7 +352,11 @@ val dependentSegments = arrayOf( * mid* or id* for newer threads, which can be launched in new windows * or a hash for old threads, which must be loaded on old threads */ - "messages/read/?tid=id", "messages/read/?tid=mid" + "messages/read/?tid=id", "messages/read/?tid=mid", + // For some reason townhall doesn't load independently + // This will allow it to load, but going back unfortunately messes up the menu client + // See https://github.com/AllanWang/Frost-for-Facebook/issues/1593 + "/townhall/" ) inline val String?.isExplicitIntent diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt index 799b11a9..4dc6504d 100644 --- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt +++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/FbUrlTest.kt @@ -62,8 +62,8 @@ class FbUrlTest { */ @Test fun queryConversion() { - val url = "${FB_URL_BASE}l.php?u=https%3A%2F%2Fgoogle.ca&h=hi" - val expected = "https://google.ca?h=hi" + val url = "${FB_URL_BASE}l.php?u=https%3A%2F%2Fgoogle.ca&qc=hi" + val expected = "https://google.ca?qc=hi" assertFbFormat(expected, url) } -- cgit v1.2.3