Skip to content

Consilidate wallet search#477

Open
gemdev111 wants to merge 14 commits into
mainfrom
consilidate-wallet-search
Open

Consilidate wallet search#477
gemdev111 wants to merge 14 commits into
mainfrom
consilidate-wallet-search

Conversation

@gemdev111

@gemdev111 gemdev111 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

closes #354

images:

Browse
tags · recents · perpetuals · assets
Pinned
perpetual + asset, one section
Search "btc"
ranked perps + assets
1-browse 2-browse-pinned 3-search-btc-perps+assets
Contract search
token id → Tether
Perpetuals ›
market screen
Assets ›
read-only, capped 100
4-contract-search-tether 5-perpetuals-market 6-assets-results
Perpetual detail
opened from search
Empty state
no results → Add Custom Token
7-perpetual-detail 8-browse-empty

gemdev111 added 6 commits June 9, 2026 14:33
Introduce a single search_priority table keyed by (query, type,
item_id) to replace assets_priority, with Migration 79->80 and the
exported schema.
Rank results via search_priority joins and match assets by
contract/tokenId in local asset search.
Expose the unified /v1/search endpoint returning assets and
perpetuals behind a GemSearch coordinator alongside SearchAssets.
Fetch via GemSearch and persist assets, perpetuals, and ranking;
wire repositories, DI, and showPerpetuals gating.
Make assetRows public, add getAssetBadge, and support clickable
section headers via nullable SubheaderItem onClick.
Port the iOS WalletSearchScene/AssetsResultsScene flow — sections,
preview limits, onAction routing, perpetuals gating — and replace the
old AssetsSearchScreen.
@gemdev111 gemdev111 self-assigned this Jun 9, 2026
gemdev111 added 7 commits June 9, 2026 20:34
Pinned perpetuals and pinned assets share the Pinned header but were
positioned independently, so a single pinned perpetual plus a single
pinned asset rendered as two separate rounded cards instead of one joined
card like iOS. Position both sub-lists against the combined count via
itemsPositioned indexOffset/totalCount, and drop the now-unused
getListPosition extension.
hasPriorities() is a Room flow that re-emits on every search_priority
write, and the flatMapLatest keyed on it lacked distinctUntilChanged, so a
repeated search for the same query restarted the inner query and reloaded
the list. Add distinctUntilChanged across asset, swap, and perpetual
search; priority ranking still updates reactively through the JOIN.
The network token search hung off the 5-input filters flow, firing on
session/filter churn rather than only query/tag and without a real
debounce, so fast typing launched overlapping searches racing on the
no-results state. Drive it off a distinct (query, tag, currency, chains)
stream with collectLatest, matching iOS which searches only on user input.

Gate the trigger behind remoteSearch and disable it on the AssetsResults
drill-down, which re-fetched results already in the store and rewrote
search_priority, forcing a reload. It now renders straight from the store
like iOS's read-only results view model.
Catch blocks on the token search path rethrow CancellationException so a
search cancelled by a newer query under collectLatest stops instead of
completing as a failure and writing a stale no-results marker.

Move the remoteSearch toggle from an open property read in the base class
init, a virtual call during construction, to a constructor parameter.
Only wallet search reset the tag when the user typed; Send, Buy, Swap, and
price alert pickers kept it applied invisibly (the tag bar hides while
typing), filtered results by query::tag so the local LIKE fallback matched
nothing, and restored the stale tag when the query cleared. iOS resets the
tag on search focus in every picker via SelectAssetViewModel.onChangeFocus.
Move the rule from WalletSearchViewModel into the shared base.
@gemdev111 gemdev111 marked this pull request as ready for review June 10, 2026 09:16
# Conflicts:
#	android/data/repositories/src/main/kotlin/com/gemwallet/android/data/repositories/assets/AssetsRepository.kt
#	android/data/repositories/src/main/kotlin/com/gemwallet/android/data/repositories/di/AssetsModule.kt
#	android/data/repositories/src/test/kotlin/com/gemwallet/android/data/repositories/assets/AssetsRepositoryTest.kt
perpetuals.map { PerpetualData(perpetual = it.perpetual, asset = it.asset, metadata = PerpetualMetadata(isPinned = false)) }
)
searchPriorityDao.put(perpetuals.toSearchPriority(priorityQuery))
} catch (err: CancellationException) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

too much } catch (err: CancellationException) {
throw err handling,

@Test
fun search_ingestsPerpetualsAndStoresPerpPriority() = runTest {
val perpAsset = mockAsset()
val perpetual = Perpetual(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use mock() for perp

import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

useless unit test

override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("DROP TABLE IF EXISTS `assets_priority`")
db.execSQL(
"CREATE TABLE IF NOT EXISTS `search_priority` (" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this consistent with ios naming?

searchable = false,
onChainFilter = {},
onBalanceFilter = {},
onClearFilters = {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

too many methods? can we create onAction(action), and action is a enum? we have some examples

@@ -0,0 +1,9 @@
package com.gemwallet.android.features.assets.viewmodels

object WalletSearchLimits {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we move those limits to gemstone? so it's reused for ios and android

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.

Consolidate global search

2 participants