Skip to content

feat(booking): allow renters and lenders to cancel bookings - #363

Merged
adrimikh merged 7 commits into
mainfrom
feature/cancel-booking
Nov 18, 2026
Merged

adrimikh merged 7 commits into
mainfrom
feature/cancel-booking

Conversation

@adrimikh

Copy link
Copy Markdown
Contributor

Summary

Closes #336. Add renter booking retrieval and cancellation for renters and lenders. Only eligible bookings can be cancelled, and ViewModel exposes loading, pending, and error states.

What

  • Add renter bookings query and status-only cancellation write.
  • Allow verified renters and lenders to cancel REQUESTED or CONFIRMED bookings.
  • Track booking loads and cancellations in the ViewModel; prevent duplicate in-flight cancellations.
  • Add repository, ViewModel, and Firestore rules tests.

Why

Renters and lenders need a safe way to cancel bookings. Firestore rules prevent stale or unauthorized writes from changing booking fields beyond status.

Validation

  • ./gradlew ktfmtCheck — Passed.
  • ./gradlew testDebugUnitTest — Passed.

Follow-ups

AI use

Copilot helped writing the code, I reviewed and tested it.

@lucaschristiansson lucaschristiansson 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.

Superseded by my later review, which has the comments inline on the code.

@lucaschristiansson lucaschristiansson 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.

Reviewed against .github/skills/code-review/SKILL.md. Details are in the inline comments linked below.

Point Result Notes
Scope OK One task.
Tests ISSUE Don't compile on main; nitpicks here and here.
Architecture OK No Firebase in the ViewModel.
Offline Question Pending while offline; KDoc wording.
Security OK Tight update rule, one question.
Clarity Question Lender side.

Nitpick: the Validation section lists testDebugUnitTest but not ./gradlew check or the rules tests.

Requesting changes for the compile failure only; everything else is a question or a nitpick.

Comment thread firestore.rules Resolved
Comment thread rules-tests/firestore.test.js Resolved
@sonarqubecloud

Copy link
Copy Markdown

@lucaschristiansson lucaschristiansson 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.

Thanks for the quick and thorough follow-up: every earlier comment is either fixed or answered.

Point Result Notes
Scope OK One task.
Tests OK The compile failure is fixed: main is merged in and days is stubbed. All test sources compile and the booking tests pass on my machine. The tests cover late rejection, rejection before returning, retry, duplicate taps and the already-cancelled case. CI and the rules check are green.
Architecture OK No Firebase in the ViewModel.
Offline OK Cancelling now updates the list right away and goes back to the old status if the server rejects the write. The KDoc wording is fixed too.
Security OK The update rule is unchanged and tight. Allowing cancellation of bookings whose days have passed is intended, as you explained.
Clarity OK The lender list is planned for #361, as you explained. One optional nitpick inline.
AI acknowledgement OK Copilot is named, and every changed file has the sign-off headers.

Nitpick: the Validation section still lists only testDebugUnitTest. Could you add ./gradlew check and the rules tests?

Approving. The remaining points are nitpicks and don't block merging.

@adrimikh
adrimikh merged commit 28b1583 into main Nov 18, 2026
4 checks passed
@adrimikh
adrimikh deleted the feature/cancel-booking branch November 18, 2026 12:52
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.

Update model and firestore rules for cancel booking

2 participants