@@ -8,6 +8,9 @@ import com.flipcash.app.core.navigation.DeeplinkType
88import com.flipcash.app.core.navigation.Key
99import com.flipcash.app.core.navigation.fragments
1010import com.flipcash.app.router.Router
11+ import com.flipcash.app.router.internal.AppRouter.Companion.cashLink
12+ import com.flipcash.app.router.internal.AppRouter.Companion.login
13+ import com.flipcash.app.router.internal.AppRouter.Companion.pool
1114import com.flipcash.services.user.AuthState
1215import com.flipcash.services.user.UserManager
1316import dev.theolm.rinku.DeepLink
@@ -55,36 +58,39 @@ internal class AppRouter(
5558
5659 override fun processType (deeplink : DeepLink ? ): DeeplinkType ? {
5760 return deeplink?.let {
58- when (deeplink.pathSegments.size) {
59- 1 -> {
60- when {
61- login.contains( deeplink.pathSegments[ 0 ] ) -> {
62- val uri = deeplink.data.toUri()
63- var entropy = uri.fragments[ Key .entropy]
64- if (entropy == null ) {
65- entropy = uri.getQueryParameter( " data " )
66- }
61+ when {
62+ deeplink.isLogin() -> deeplink.handleLoginLink()
63+ deeplink.isCashLink() -> deeplink.handleCashLink()
64+ deeplink.isPool( ) -> deeplink.handlePoolLink()
65+ else -> null
66+ }
67+ }
68+ }
69+ }
6770
68- entropy ? : return null
71+ private fun DeepLink.isLogin (): Boolean = login.contains(pathSegments[0 ])
72+ private fun DeepLink.isCashLink (): Boolean = cashLink.contains(pathSegments[0 ])
73+ private fun DeepLink.isPool (): Boolean = pool.contains(pathSegments[0 ])
6974
70- DeeplinkType .Login (entropy)
71- }
75+ private fun DeepLink.handleLoginLink (): DeeplinkType .Login ? {
76+ val uri = data.toUri()
77+ var entropy = uri.fragments[Key .entropy]
78+ if (entropy == null ) {
79+ entropy = uri.getQueryParameter(" data" )
80+ }
7281
73- cashLink.contains(deeplink.pathSegments[0 ]) -> {
74- val entropy = deeplink.data.toUri().fragments[Key .entropy] ? : return null
82+ entropy ? : return null
7583
76- DeeplinkType .CashLink (entropy)
77- }
84+ return DeeplinkType .Login (entropy)
85+ }
7886
79- pool.contains(deeplink.pathSegments[0 ]) -> {
80- val seed = deeplink.data.toUri().fragments[Key .entropy] ? : return null
81- DeeplinkType .Pool (seed)
82- }
83- else -> null
84- }
85- }
86- else -> null
87- }
88- }
89- }
87+ private fun DeepLink.handleCashLink (): DeeplinkType .CashLink ? {
88+ val entropy = data.toUri().fragments[Key .entropy] ? : return null
89+
90+ return DeeplinkType .CashLink (entropy)
91+ }
92+
93+ private fun DeepLink.handlePoolLink (): DeeplinkType .Pool ? {
94+ val seed = data.toUri().fragments[Key .entropy] ? : return null
95+ return DeeplinkType .Pool (seed)
9096}
0 commit comments