Skip to content

Conversation

@Fabtron
Copy link
Collaborator

@Fabtron Fabtron commented Dec 18, 2023

What's new?

Fixed crash of the checkout activity caused of an npe in the payment status view if the user opens the app and is not checked in anymore.

APPS-1261

How to test?

  • Apply this patch on the main branch :
index c9d00d905..3dcd483e3 100644
--- a/ui/src/main/java/io/snabble/sdk/ui/checkout/PaymentStatusFragment.kt
+++ b/ui/src/main/java/io/snabble/sdk/ui/checkout/PaymentStatusFragment.kt
@@ -1,6 +1,20 @@
 package io.snabble.sdk.ui.checkout
 
+import android.os.Bundle
+import androidx.lifecycle.lifecycleScope
+import io.snabble.sdk.Snabble
 import io.snabble.sdk.ui.BaseFragment
 import io.snabble.sdk.ui.R
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
 
-open class PaymentStatusFragment : BaseFragment(R.layout.snabble_fragment_payment_status)
\ No newline at end of file
+open class PaymentStatusFragment : BaseFragment(R.layout.snabble_fragment_payment_status){
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        lifecycleScope.launch {
+            delay(4000)
+            Snabble.checkedInProject.value = null
+        }
+    }
+}

  • Buy something -> after 4 sec the checkout should crash (see logs)
  • Apply the same patch on this branch :

Now the logs should show the following log :
2023-12-18 08:33:57.843 11885-11885 (CheckoutA....java:135) io.snabble.sdk.sample E Project not set

Definition of Done

  • Changelog gepflegt
  • Dokumentation gepflegt
  • Alle Anforderung des Issues sind erfüllt
  • Selbst greviewed (aka Self-Reviews (eng))

@Fabtron Fabtron requested a review from cmaier December 18, 2023 07:44
@cmaier
Copy link
Contributor

cmaier commented Dec 18, 2023

Cannot reproduce the bug w/ this patch. What am I doing wrong?

@Fabtron Fabtron merged commit a5b3547 into main Dec 18, 2023
@Fabtron Fabtron deleted the apps-1261-fix-checkout-crash branch December 18, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants