fix(market): search your zone by a coarse prefix, not the exact cell

Discovery searched the full 5-char geohash (~2.4 km) with an exact Nostr tag
match, so two devices in adjacent cells never found each other even though
publish emits the full NIP-52 prefix ladder. Search now coarsens the area to a
configurable precision (SocialSettings.searchPrecision, default 4 ~20 km) via
searchPrefix(), with a human-worded 'how far' selector (Very close / Around
here / My region -> 5/4/3) in the market setup sheet.

Also: surface a clear 'couldn't reach the servers' message when no relay
accepts a share (instead of 'shared 0'), and add wss://relay.comunes.org as the
first default relay (reliable community home; public relays are backup).

Tests: settings precision (default/clamp/roundtrip), searchPrefix helper,
neighbour-cell discovery regression (offers_cubit + commons_core nostr
transports), and the range-selector widget test.
This commit is contained in:
vjrj 2026-07-10 16:12:38 +02:00
parent 1fb8e37536
commit 97b9223cb2
16 changed files with 268 additions and 10 deletions

View file

@ -0,0 +1,11 @@
/// The geohash prefix to search offers by, given the user's coarse [area] and
/// the chosen [precision] (a prefix length; see
/// `SocialSettings.searchPrecision`).
///
/// Publishing emits a NIP-52 prefix ladder from the (already coarse) area, so a
/// SHORTER search prefix still matches finer offers. Searching at the full area
/// length only matches the exact ±2.4 km cell which is why two neighbours in
/// adjacent cells used to find nothing. We recorten the area to [precision] (but
/// never beyond its own length) so "your zone" is genuinely a zone, not a point.
String searchPrefix(String area, int precision) =>
area.substring(0, area.length < precision ? area.length : precision);