← back to Homesonspec
homesonspec/mobile: Cycle 2 Cody fixes — homeDetailUrl /home->/homes (was 404), drop wrong-price DOM scrape (blank > confidently-wrong; Cycle 3 enriches from /api/map by id)
6abe8f2e64bcd8bf33cad4596ab50d7ae76dcd4e · 2026-08-06 13:32:43 -0700 · Steve
Files touched
M apps/mobile/app/(tabs)/browse.tsxM apps/mobile/lib/api.ts
Diff
commit 6abe8f2e64bcd8bf33cad4596ab50d7ae76dcd4e
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Aug 6 13:32:43 2026 -0700
homesonspec/mobile: Cycle 2 Cody fixes — homeDetailUrl /home->/homes (was 404), drop wrong-price DOM scrape (blank > confidently-wrong; Cycle 3 enriches from /api/map by id)
---
apps/mobile/app/(tabs)/browse.tsx | 23 +++++++++--------------
apps/mobile/lib/api.ts | 3 ++-
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/apps/mobile/app/(tabs)/browse.tsx b/apps/mobile/app/(tabs)/browse.tsx
index 638b503d..c58ec89e 100644
--- a/apps/mobile/app/(tabs)/browse.tsx
+++ b/apps/mobile/app/(tabs)/browse.tsx
@@ -56,29 +56,24 @@ const INJECTED_CSS = `
/**
* Injected JS that posts a message to RN when the user taps a home-detail page.
* Verified against the LIVE PDP (/homes/:id, Cycle 2): the h1 holds the home's
- * street address (present in SSR). There are NO data-price/data-location
- * attributes on the page, so those are best-effort text-scan fallbacks:
- * price -> first "$NNN,NNN" in the visible text, stored digits-only
- * location -> first "City, ST" pattern
- * Best-effort; the save still works on id + title alone if these miss.
- * FOLLOW-UP (Cycle 3): enrich price/city/status by home id from /api/map
- * instead of scraping the DOM — the app already has that dataset.
+ * street address (present in SSR) and is reliable. There are NO
+ * data-price/data-location attributes, and a naive first-"$NNN,NNN" text scan
+ * grabs the WRONG number (a "From $X" base price or a "$X/mo" payment banner),
+ * so we deliberately do NOT scrape price/location from the DOM — a confidently
+ * wrong price is worse than a blank one. We capture only the reliable title + url.
+ * Price/city/status are filled correctly in Cycle 3 by looking the home up by id
+ * in the /api/map dataset the app already loads.
*/
const INJECTED_SAVE_BRIDGE = `
(function() {
try {
var h1 = document.querySelector('h1');
- var bodyText = (document.body && document.body.innerText) || '';
- var priceEl = document.querySelector('[data-price]');
- var priceMatch = bodyText.match(/\\$[0-9]{1,3}(?:,[0-9]{3})+/);
- var locEl = document.querySelector('[data-location]');
- var locMatch = bodyText.match(/[A-Za-z .'-]{2,},\\s*[A-Z]{2}\\b/);
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify({
type: 'PAGE_CHANGE',
url: window.location.href,
title: (h1 && h1.innerText) || '',
- price: (priceEl && priceEl.dataset && priceEl.dataset.price) || (priceMatch ? priceMatch[0].replace(/[^0-9]/g, '') : ''),
- location: (locEl && locEl.dataset && locEl.dataset.location) || (locMatch ? locMatch[0] : ''),
+ price: '',
+ location: '',
}));
} catch(e) {}
true;
diff --git a/apps/mobile/lib/api.ts b/apps/mobile/lib/api.ts
index 40db3b0e..bf289af1 100644
--- a/apps/mobile/lib/api.ts
+++ b/apps/mobile/lib/api.ts
@@ -89,7 +89,8 @@ export async function fetchFacets(): Promise<FacetsResponse> {
* Used from the Saved tab to open a saved home in the WebView.
*/
export function homeDetailUrl(homeId: string): string {
- return `${BASE_URL}/home/${homeId}`;
+ // Live PDP path is /homes/:id (plural). /home/:id 404s (verified Cycle 2).
+ return `${BASE_URL}/homes/${homeId}`;
}
/** Base URL for the WebView (Browse tab). */
← f8ba090b DEPLOY.md: document deploy-web.sh as the sanctioned safe web
·
back to Homesonspec
·
homesonspec/mobile: Cycle 3 — enrich Saved by id from /api/m 24cb9a13 →