Skip to content

Commit

Permalink
simplified showTickets condition check as suggested by @oguzkocer
Browse files Browse the repository at this point in the history
  • Loading branch information
mzorz committed Jul 20, 2018
1 parent 22ece0b commit 57b7759
Showing 1 changed file with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class HelpActivity : AppCompatActivity() {
intent.extras?.get(WordPress.SITE) as SiteModel?
}

private var mTicketsBeingShown: Boolean = false

override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleManager.setLocale(newBase))
}
Expand Down Expand Up @@ -80,12 +78,13 @@ class HelpActivity : AppCompatActivity() {
AnalyticsTracker.track(Stat.SUPPORT_IDENTITY_FORM_VIEWED)
}

if (savedInstanceState != null) {
mTicketsBeingShown = savedInstanceState.getBoolean(HelpActivity.MY_TICKETS_SHOWN_KEY)
}

if (originFromExtras == Origin.ZENDESK_NOTIFICATION && !mTicketsBeingShown) {
mTicketsBeingShown = true
/**
* If the user taps on a Zendesk notification, we want to show them the `My Tickets` page. However, this
* should only be triggered when the activity is first created, otherwise if the user comes back from
* `My Tickets` and rotates the screen (or triggers the activity re-creation in any other way) it'll navigate
* them to `My Tickets` again since the `originFromExtras` will still be [Origin.ZENDESK_NOTIFICATION].
*/
if (savedInstanceState == null && originFromExtras == Origin.ZENDESK_NOTIFICATION) {
showZendeskTickets()
}
}
Expand All @@ -96,11 +95,6 @@ class HelpActivity : AppCompatActivity() {
refreshContactEmailText()
}

override fun onSaveInstanceState(outState: Bundle?) {
outState?.putBoolean(HelpActivity.MY_TICKETS_SHOWN_KEY, mTicketsBeingShown)
super.onSaveInstanceState(outState)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
onBackPressed()
Expand Down Expand Up @@ -166,7 +160,6 @@ class HelpActivity : AppCompatActivity() {
companion object {
private const val ORIGIN_KEY = "ORIGIN_KEY"
private const val EXTRA_TAGS_KEY = "EXTRA_TAGS_KEY"
private const val MY_TICKETS_SHOWN_KEY = "MY_TICKETS_SHOWN_KEY"

@JvmStatic
fun createIntent(
Expand Down

0 comments on commit 57b7759

Please sign in to comment.