Skip to content

feat(listing): show status for every listing in toolbox - #387

Merged
peng-0110 merged 4 commits into
mainfrom
feature/toolbox-listing-status
Nov 19, 2026
Merged

peng-0110 merged 4 commits into
mainfrom
feature/toolbox-listing-status

Conversation

@peng-0110

Copy link
Copy Markdown
Contributor

Summary

Closes #196. Every listing in the Toolbox now shows its status: Paused, Booked today or Available.

What

  • BookingRepository.getBookingsForLender(): one query on lenderUid for the bookings of all the lender's listings, instead of one query per listing. The rules already allow it; a new rules test checks that a lender can list their own bookings and no one else's.
  • toolboxListingStatus (new, toolbox/model): the status is worked out from the listing and its bookings, nothing new is stored.
    • Paused if the owner paused it, whatever its bookings.
    • Booked today if a booking that isn't cancelled includes today.
    • Available otherwise, including a listing booked only on later days.
  • ToolboxViewModel loads the bookings at the same time as the listings, and reloads both whenever the profile is shown again, so a new booking appears when you come back.
  • ToolboxCard: one badge per row, the same pill shape as the existing PAUSED badge (new tag ToolboxCardTags.STATUS_BADGE), and every row stays the same height.
  • If the bookings can't be loaded (offline, for example), the listings still show: paused rows keep their badge and the others show none, rather than a possibly wrong "Available". No error banner, since the listings themselves loaded.

Why

#20 asks for "my listings with status". #355 only showed paused listings, so owners still couldn't tell which of their listings are booked today.

#196 suggested adding a status field to the model, writes and rules. Lenders can't approve or reject a request yet, so for now the status is derived from the data that already exists, and a request that covers today counts as booked. That avoids a stored field that would need migrating once approval exists.

Validation

  • ./gradlew ktfmtCheck check passes locally: 1615 unit tests, 0 failures.
  • Rules tests (rules-tests, emulators): 214 pass, including the new lender query test.
  • New tests:
    • ToolboxListingStatusTest: paused wins over a booking today, booked today, a booking whose separate days skip today, only later bookings, a confirmed booking, cancelled and past bookings, and other listings' bookings.
    • ToolboxViewModelTest: statuses after loading, loading until the bookings arrive, a failure of the bookings alone, keeping the statuses on a failed reload, and reloading the bookings.
    • ToolboxCardTest: one badge per row, no badges but Paused before the bookings load, the same row height for every status, and the card with its ViewModel.
    • FirebaseBookingRepositoryTest: the lender query, and a signed-out user being refused.
  • Not run: connectedCheck (instrumented tests), and not checked on a device.

Follow-ups

  • Once lenders can approve or reject requests, "Booked today" should count approved bookings only (no issue yet).

AI use

Claude Code (Claude Opus 5.5) wrote the lender bookings query, the status logic, the badges and the tests, and ran the checks. I reviewed the diff.

One query on lenderUid, which the rules already allow, so the Toolbox can show each listing's status without a query per listing.
Every Toolbox row shows Paused, Booked today or Available, derived from the listing and its bookings. Lenders cannot approve requests yet, so a request that is not cancelled and covers today counts as booked.
@peng-0110
peng-0110 requested a review from adrimikh November 19, 2026 07:59

@adrimikh adrimikh left a comment

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.

The derived status logic is straightforward, and the parallel listing/bookings load avoids making users wait for a second network round trip. The rules test also gives good coverage for querying bookings across a lender’s listings.
I just requested a few changes and then everything will be good.

A failed reload kept the bookings of the last load, so a listing could still show Available or Booked today after a booking changed, with no error to say it was out of date. The bookings are now dropped on failure, and the failure is logged.
…ng-status

# Conflicts:
#	app/src/sharedTest/java/com/android/polybazaar/booking/model/FakeBookingRepository.kt
@sonarqubecloud

Copy link
Copy Markdown

@adrimikh adrimikh left a comment

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.

LGTM

@peng-0110
peng-0110 merged commit 992ef56 into main Nov 19, 2026
4 checks passed
@peng-0110
peng-0110 deleted the feature/toolbox-listing-status branch November 19, 2026 15:46
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.

Show each listing's status in the Toolbox

2 participants