Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] in landscape marking as paid with cash keeps user on collect payment screen #12632

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.woocommerce.android.ui.woopos.cardreader.WooPosCardReaderActivity
import com.woocommerce.android.ui.woopos.cardreader.WooPosCardReaderPaymentStatus
import com.woocommerce.android.util.ChromeCustomTabUtils
import com.woocommerce.android.util.UiHelpers
import com.woocommerce.android.util.WooLog
import com.woocommerce.android.viewmodel.MultiLiveEvent.Event.ShowDialog
import com.woocommerce.android.viewmodel.MultiLiveEvent.Event.ShowSnackbar
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -244,8 +245,11 @@ class SelectPaymentMethodFragment : BaseFragment(R.layout.fragment_select_paymen
// We should pop the back stack to show the [OrderDetailsFragment].
findNavController().popBackStack()
} else {
if (isFragmentInBackStack(R.id.selectPaymentMethodFragment)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one partial fix if we can't come up with a better solution. But it only takes us back to the order detail screen.

findNavController().popBackStack()
}
SelectPaymentMethodFragmentDirections.actionSelectPaymentMethodFragmentToOrderList().run {
findNavController().navigateSafely(this)
findNavController().navigateSafely(this, true)
}
}
}
Expand Down Expand Up @@ -305,6 +309,16 @@ class SelectPaymentMethodFragment : BaseFragment(R.layout.fragment_select_paymen
}
}

private fun isFragmentInBackStack(destinationId: Int): Boolean {
return try {
findNavController().getBackStackEntry(destinationId)
true
} catch (e: IllegalArgumentException) {
WooLog.e(WooLog.T.POS, "Unable to find fragment", e)
false
}
}

private fun ReturnResultToWooPos.asWooPosCardReaderPaymentResult() =
when (this) {
is ReturnResultToWooPos.Success -> WooPosCardReaderPaymentStatus.Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
app:popUpToInclusive="false" />
<action
android:id="@+id/action_selectPaymentMethodFragment_to_orderList"
app:popUpTo="@+id/orders"
app:destination="@+id/orders"
app:popUpToInclusive="false" />
<action
android:id="@+id/action_selectPaymentMethodFragment_to_orderDetailFragment"
Expand Down
Loading