Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

375
Views
How to make a sound when there is an increase in the counter but not a decrease

I am making a call to my firebase database as follows:

//reference from firebase for enquiries
       const Ref = projectDatabase .ref("list").child("enquiries");
            Ref.on("value", (snapshot) => {
  enquiries.value = Object.getOwnPropertyNames(snapshot.val()).length
    });

Everytime a new enquiry comes in (making the length go up by 1) I want to play a sound. But I dont want the sound to play if I delete an enquiry (which makes it go down by 1).

What I tried to implement is :

const sound = ref(new Audio('https://firebasestorage.googleapis.com/v0/b/homejigapp.appspot.com/o/mixkit-positive-notification-951%20(1).wav?alt=media&token=b1452d74-0af3-4da5-b907-c7f94f55d013'));

    //reference from firebase for enquiries
           const Ref = projectDatabase .ref("list").child("enquiries");
                Ref.on("value", (snapshot) => {
      enquiries.value = Object.getOwnPropertyNames(snapshot.val()).length
        sound.value.play();
        });

The issue is that the sound plays every time a user gets on the screen and even when the user rejects an enquiry (so the enquiry length goes down by 1).

Is there a way to make the sound play like an inbox alert (only when a new enquiry comes into the database). A cloud function maybe?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!