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

Implement deep link for advanced search results #341

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@
android:scheme="https" />
</intent-filter>

<intent-filter
android:autoVerify="true"
android:label="Advanced Search">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="primal.net"
android:pathPrefix="/asearch/"
android:scheme="https" />
</intent-filter>

<intent-filter android:label="Wallet Connect">
<action android:name="android.intent.action.VIEW" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ fun SharedTransitionScope.PrimalAppNavigation() {
navController.navigateToArticleDetails(deepLink.naddr)
}

is DeepLink.AdvancedSearch -> {
navController.popBackStack()
navController.navigateToExploreFeed(feedSpec = deepLink.feedSpec)
}

null -> navController.navigateToHome()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ sealed class DeepLink {
data class Note(val noteId: String) : DeepLink()
data class Article(val naddr: String) : DeepLink()
data class PrimalNWC(val primalWalletNwc: PrimalWalletNwc) : DeepLink()
data class AdvancedSearch(val feedSpec: String) : DeepLink()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import net.primal.android.user.domain.parseNWCUrl
private val PRIMAL_NOTE_REGEX = Regex("https://.*primal.net/e/")
private val PRIMAL_ARTICLE_REGEX = Regex("https://.*primal.net/a/")
private val PRIMAL_PROFILE_REGEX = Regex("https://.*primal.net/p/")
private val PRIMAL_ADVANCED_SEARCH = Regex("https://.*primal.net/asearch/")

private const val NOSTR_WALLET_CONNECT_SCHEMA = "nostr+walletconnect://"
private const val NOSTR_WALLET_CONNECT_ALT_SCHEMA = "nostrwalletconnect://"
Expand All @@ -34,6 +35,11 @@ fun String.parseDeepLinkOrNull(): DeepLink? =
unknownArticleIdentifier.let { DeepLink.Article(it) }
}

PRIMAL_ADVANCED_SEARCH.containsMatchIn(this) -> {
val unknownArticleIdentifier = PRIMAL_ADVANCED_SEARCH.replace(this, "")
unknownArticleIdentifier.let { DeepLink.AdvancedSearch(it) }
}

isNostrWalletConnectSchemaAndUrl() ->
runCatching {
DeepLink.NostrWalletConnect(nwc = this.parseNWCUrl())
Expand Down