Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

376
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda