Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admins hear success/error sounds when adding items to a pickup for a reservation #1827

Merged
merged 5 commits into from
Feb 8, 2025

Conversation

crismali
Copy link
Contributor

@crismali crismali commented Jan 29, 2025

What it does

Adds sounds when adding/removing items to a pickup for a reservation

Why it is important

#1793

Audio Interface Changes

You can test the sounds using the seed data by visiting the approved reservation's page and clicking on "Start Building".

  • for the "neutral" sound, add an item that is not part of the reservation
  • for the "success" sound, add an item that is part of the reservation
  • for the "failure" sound, add an item that does not exist
  • for the "removed" sound, remove something that you've already added

Implementation notes

I added a custom turbo stream action called playSound. Right now it should only play sounds if the audio tags are loaded on the page.

I didn't really add any tests since the general functionality of this part of the app is already tested and the sounds feel like a bonus. System testing this behavior seemed weird (I'm not really sure you can test this sort of thing with them) and so did controller testing controller instance variables or the turbo stream markup.

@crismali crismali force-pushed the michael-1793-sounds-for-pickups branch from 9b9b0fb to c51e5d3 Compare February 3, 2025 22:06
@crismali crismali force-pushed the michael-1793-sounds-for-pickups branch from c51e5d3 to d4e1ca1 Compare February 7, 2025 22:38
admin_reservation_loans_path(@pending_reservation_item.reservation))
)
@sound_type = success_sound_path
render_turbo_response(:update)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a file seemed like the easiest way to send down multiple turbo streams.

@reservation_loan = ReservationLoan.new
@reservation_loan.errors.add(:reservable_item_number, message)
render_form
end

def render_form
render partial: "admin/reservations/reservation_loans/form", locals: {reservation: @reservation, reservation_loan: @reservation_loan}, status: :unprocessable_entity
render_turbo_response :create_error, status: :unprocessable_entity
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This create_error pattern seemed to be hanging around other parts of the app so I just copied that.

@crismali crismali marked this pull request as ready for review February 7, 2025 23:30
@crismali crismali requested review from jim and a team February 7, 2025 23:30
Copy link
Member

@jim jim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!

I tested this out and it's working really well!

I diid notice that sometimes if you enter new items fast, a sound doesn't get played (I imagine because it's already playing?).

We can maybe call fastSeek or load on the audio just before calling play? It's not a big deal if a sound gets interrupted, but that might guarantee we get it to play every time.

In any case, I think we can iterate on the details (and get feedback from staff), but this is an exciting step into a bright multimedia future! 🚀 🔈 🎉

@crismali crismali merged commit 4c8e464 into main Feb 8, 2025
9 checks passed
@crismali crismali deleted the michael-1793-sounds-for-pickups branch February 8, 2025 16:37
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.

2 participants