Skip to content

Commit

Permalink
Merge pull request #1461 from WalletConnect/fix/nav_controller_not_in…
Browse files Browse the repository at this point in the history
…itialized

Fix for nav controller not initialized on deep link
  • Loading branch information
jakubuid authored Jul 31, 2024
2 parents 93507e7 + 6d192c5 commit 4b5167e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,6 @@ class Web3WalletActivity : AppCompatActivity() {
}

private fun handleAppLink(intent: Intent?) {
if (intent?.dataString?.contains("wc_ev") == true) {
Web3Wallet.dispatchEnvelope(intent.dataString ?: "") {
lifecycleScope.launch(Dispatchers.Main) {
Toast.makeText(this@Web3WalletActivity, "Error dispatching envelope: ${it.throwable.message}", Toast.LENGTH_SHORT).show()
}
}
}
}

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)

if (intent?.dataString?.contains("wc_ev") == true) {
Web3Wallet.dispatchEnvelope(intent.dataString ?: "") {
lifecycleScope.launch(Dispatchers.Main) {
Expand All @@ -208,11 +196,21 @@ class Web3WalletActivity : AppCompatActivity() {
if (intent?.dataString?.startsWith("kotlin-web3wallet://request") == false
&& intent.dataString?.contains("requestId") == false
) {
navController.handleDeepLink(intent)
lifecycleScope.launch {
navigateWhenReady {
navController.handleDeepLink(intent)
}
}
}
}
}

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)

handleAppLink(intent)
}

private fun askNotificationPermission() {
// This is only necessary for API level >= 33 (TIRAMISU)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ fun Web3WalletNavGraph(
navController.addOnDestinationChangedListener(
listener = { _, destination, _ ->
if (destination.route == Route.Connections.path) {
WCDelegate.sessionRequestEvent = null
WCDelegate.currentId = null
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ class SessionRequestViewModel : ViewModel() {
method = sessionRequest.request.method,
peerContextUI = context.toPeerUI()
)
} else SessionRequestUI.Initial
} else {
SessionRequestUI.Initial
}
}
}

Expand Down

0 comments on commit 4b5167e

Please sign in to comment.