Skip to content

chore(presentation): consolidate canRequestRide predicate into FollowedDriversRepository.canRequestRide(_:) #94

@variablefate

Description

@variablefate

Background

DriverDetailViewState.from() and RideRequestDriverOption.from() inline the
predicate driver.hasKey && !isKeyStale && location?.status == "online" for
canRequestRide, instead of calling the SDK-side
FollowedDriversRepository.canRequestRide(_:) that already exists.

History

This drift was first surfaced in PR #58's 4th-pass review and re-flagged in PR
#61's review as a follow-up to fix at next touch. PR #93 (Kind 30173 vehicle
work) did modify DriverDetailViewState.swift (added a vehicle: parameter)
but kept the inline predicate to honour PR #91's "don't widen scope" constraint.

Why it matters

  • The inline predicate omits the "driver exists in repo" guard pinned by
    CanRequestRideTests.staleCallerSnapshot_hasKeyButRepoMissingKey_returnsFalse
    on the SDK side. Practically harmless today (callers always pass a real
    FollowedDriver), but a real semantic gap.
  • Two divergent definitions of "rider can request a ride from this driver" make
    future protocol-level changes (e.g. new key staleness conditions) risky:
    callers updating one definition and forgetting the other would silently drift
    the UI from the SDK contract.

Scope

Consolidate the inline predicate in:

  • RoadFlare/RoadFlareCore/Presentation/DriverDetailViewState.swift
  • RoadFlare/RoadFlareCore/Presentation/RideRequestDriverOption.swift

into calls to FollowedDriversRepository.canRequestRide(_:). Update the
factory signatures to accept canRequestRide: Bool (resolved by
AppState+Presentation) rather than re-deriving from raw inputs. Update
existing tests to feed the resolved boolean.

Effort

Small — one-shot refactor + test churn. No protocol changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions