From 7659f2741e3586ec1be4094c0f2c46ad6a7a9522 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 9 Oct 2026 17:42:00 +0200 Subject: [PATCH] refactor(places): drop the unused phone pool counter poolCounts in the phone places browser model has had no caller since the phone pool chips stopped showing counts in 8855b5581 (the FilterChip note in MPlacesBrowser says counts are left out on the phone to save row space). Only its own tests still ran it, and it had drifted from the desktop counts in usePlacesSidebar, which count planned places against the day scoped planned ids. Nothing on the phone should use it, so it goes, with its two tests. No user facing change, so there is no red test: the helper is dead code. Removed tests in src/mobile/screens/trip/places/placesBrowserModel.test.ts: MOBILE-POOL-counts (expected all 3, planned 2, unplanned 1) and FE-MOB-PMODEL-013 (expected all 2, tracks 1, planned 1, unplanned 1). --- .../trip/places/placesBrowserModel.test.ts | 17 +---------------- .../screens/trip/places/placesBrowserModel.ts | 13 +------------ 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/client/src/mobile/screens/trip/places/placesBrowserModel.test.ts b/client/src/mobile/screens/trip/places/placesBrowserModel.test.ts index f6607f302..4c1a521db 100644 --- a/client/src/mobile/screens/trip/places/placesBrowserModel.test.ts +++ b/client/src/mobile/screens/trip/places/placesBrowserModel.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect } from 'vitest' import { filterPool, firstPlannedDayNumbers, matchesSearch, - plannedPlaceIds, poolCounts, + plannedPlaceIds, } from './placesBrowserModel' import { matchesCategoryFilter } from '../../../../utils/placesFilter' import type { AssignmentsMap, Day, Place } from '../../../../types' @@ -34,13 +34,6 @@ describe('placesBrowserModel — planned pool', () => { const out = filterPool(named, { filter: 'planned', categoryFilters: noCats, search: 'eiff', plannedIds }) expect(out.map(p => p.id)).toEqual([3]) }) - - it('MOBILE-POOL-counts: poolCounts reports planned alongside all/unplanned', () => { - const c = poolCounts(places, noCats, '', plannedIds) - expect(c.all).toBe(3) - expect(c.planned).toBe(2) - expect(c.unplanned).toBe(1) - }) }) // FE-MOB-PMODEL-001 to FE-MOB-PMODEL-012 @@ -157,14 +150,6 @@ describe('placesBrowserModel — tracks pool', () => { expect(all.map(p => p.id)).toEqual([1, 2, 3]) }) - it('FE-MOB-PMODEL-013: poolCounts counts tracks on the category+search base set', () => { - const c = poolCounts(places, new Set(['4']), '', plannedIds) - expect(c.all).toBe(2) - expect(c.tracks).toBe(1) - expect(c.planned).toBe(1) - expect(c.unplanned).toBe(1) - }) - // #2072 — the phone pool has to agree with the desktop one; both ask the same // shared helper now. it('FE-MOB-PMODEL-014: a stay and a day-anchored booking both count as planned', () => { diff --git a/client/src/mobile/screens/trip/places/placesBrowserModel.ts b/client/src/mobile/screens/trip/places/placesBrowserModel.ts index 000e334b9..53b52cfea 100644 --- a/client/src/mobile/screens/trip/places/placesBrowserModel.ts +++ b/client/src/mobile/screens/trip/places/placesBrowserModel.ts @@ -1,7 +1,7 @@ import type { AssignmentsMap, Day, Place } from '../../../../types' import { placeMatchesSearch } from '../../../../utils/placeSearch' import { - matchesCategoryFilter, matchesPlacesFilter, type PlacesRatingFloor, + matchesPlacesFilter, type PlacesRatingFloor, } from '../../../../utils/placesFilter' import { plannedPlaceIds as sharedPlannedPlaceIds, @@ -59,14 +59,3 @@ interface PoolFilterArgs { export function filterPool(places: Place[], { filter, categoryFilters, ratingFilter = 'all', search, plannedIds }: PoolFilterArgs): Place[] { return places.filter(p => matchesPlacesFilter(p, { filter, categoryFilters, ratingFilter }, { plannedIds }) && matchesSearch(p, search)) } - -/** Chip counts run on the category+search base set, like the desktop tabs. */ -export function poolCounts(places: Place[], categoryFilters: Set, search: string, plannedIds: Set) { - const base = places.filter(p => matchesCategoryFilter(p, categoryFilters) && matchesSearch(p, search)) - return { - all: base.length, - unplanned: base.filter(p => !plannedIds.has(p.id)).length, - planned: base.filter(p => plannedIds.has(p.id)).length, - tracks: base.filter(p => p.route_geometry).length, - } -}