How to handle Audio Mute on a crossplatform agora app?

I have a cross platform agora app. The Mobile version is using the Agora React Native SDK while the web version is using the Web SDK v4. When I was implementing the audio mute / unmute indication I found that the event does not trigger from mobile to web. Can anyone please help me with this, what should I do to make it work?

// This is the Code From React Native 
    const toggleAudio = useCallback(async () => {
    await RtcEngine.instance().enableLocalAudio(!audioEnabled);

    setCurrentUser(prev => {
        return { ...prev, audioEnabled: !audioEnabled }
    })
    setAudioEnabled(!audioEnabled);
}, [audioEnabled]);

And Here is the Web event Handler

 client.on("user-unpublished", (user, type) => {
            if (type === "audio") {
                user.audioTrack?.stop();
                setRemoteUsers(prev => {
                    return prev.map(ussr => ussr.uid == user.uid ? user : ussr);
                })
            }

            if (type == 'video') {
                setRemoteUsers(prev => {
                    return prev.map(ussr => ussr.uid == user.uid ? user : ussr);
                })
            }
        });

The handler works for web to web and also for the video event on mobile but doesn’t trigger the callback for the audio

Vue JS: add values from API JSon

i’m new developer in Vue JS.
below is my response body, and i wanted to add amount values that has is_paid:true with paid_amount only.. is there a way to do this in Vue JS?

{
    "payment" : {
        "installment_payment" : {
            "installments" : [
                          amount:"",
                                date: "",
                                is_paid: true,
                            },
                            {
                                amount: "",
                                date: "",
                                is_paid: false,

                            },
                            {
                                amount: "",
                                date: "",
                                is_paid: false,
                            },
                              {
                                amount: "",
                                date: "",
                                is_paid: true,
                            }
                        ],

                        remaining: ""

                    },
                    paid_amount: "",
                },]

}

Test with react-aria useButton gives me the famous “act” warning

i’m using react-aria and react testing-library.
In my Button component, i’m using react-aria’s useButton and I use onPress prop to pass the function to call once click. In the unit test, I just try to click it in order to trigger a simple jest.fn() function, and all I do after that is check if function have been called.

const handleOnClick = jest.fn();
render(<Button onPress={handleOnClick}>test me</Button>);

userEvent.click(screen.getByRole('button'));
expect(handleOnClick).toHaveBeenCalled();

That is showing the following warning:

console.error
    Warning: An update to Button inside a test was not wrapped in act(...).

    When testing, code that causes React state updates should be wrapped into act(...):

If I wrap the click with act the warning is gone, but seems it’s not a good practice to do that, because, in fact, testing library is doing an act internally in userEvent and in other methods. What can I do? Thanks.

Scroll bars not overlaying correctly

I’m trying to add scroll bars to my app so that individual sections can be scrolled, and I am expecting the styling to look like this: see desired behaviour.

However when I first load my page the scroll bars are appearing attached to the right of the parent div, rather than within it, or according to the inspector, in just enough width of padding for them to sit in. See incorrect behaviour

Currently to enable my show less/ show all option, the scroll behaviour is changed in the JS so perhaps resetting scroll behaviour is causing this?

I have tried to change the scrollbar-gutter property to auto, however this doesn’t seem to affect the scroll-bar behaviour in this case.

I have also tried to find other ways of styling the scroll bars but doesn’t seem to be much of that around.

Any help is appreciated!

End user script to automate button click for opened webpage in Edge

Browser based application, to retrieve files they have to click a button ie Get-File, depends on file queue if they receive one, may take multiple clicks. Previously had a powershell script that would emulate a key press when this was a command/dos type application.

Researching it seems Selenium may be an option with Javascript. How would this work in practice though, if the user opens the application in Edge, later navigates to the retrieve file page(where the Get-File button is), what would be the easiest way to automate the button click every few seconds. Is it possible to have a script on their desktop to double click that would somehow pickup the current active browser/tab(w pid or active window?) and have the hardcoded – uri requested every couple seconds, once they get the files needed they can just close the script?

There is a change order in place to implement a toggle switch on the webpage by the developer later on, was hoping I could get something going in the meantime. Not sure if it’s even doable.

Thanks(not looking for coding, mainly if this is possible or better idea)

How do I build an NPM package that can access a [my package]-conf.js file in the root of the main project

// this is for a Vue 3 project - not sure if that's important for the answer

// APPENDIX: 
//   package = npm package
//   project = vue 3 project that will import the npm package

I’m building an npm package that has reusable vue components using vue-sfc-rollup.

To allow for customisation I want to give the user the ability to make a config file in the root (same level as the package.json of the project) which can then be accessed by the package.

I was hoping it would look something like this.

import config from '@/my-package-conf.js' where @ (or other symbol) would indicate the root of the project

I assume this can be done using a relative path but that won’t be particularly easy for my implementation.

Thanks for any help you can provide!

Angular catching “standard” errors instead of my API’s errors

I have a service that looks like this:

return this.http
      .post(requestUrl, body, { headers, observe: 'response' })
      .toPromise()
      .then((res: any) => {
        return res.body?.data || res?.body?.message;
      }).catch((err) => {
        console.log('error', err);
      })

When i trigger an error, this is what i get on the console.log:

error Error Code: 400
Message: Http failure response for <MY API ENDPOINT>: 400 OK

But on the network tab (Google chrome dev tools) i see this:

{
    "message": "Unsupported value, please contact support.",
    "status": "failure"
}

How can i read my message that i’m sending from my Backend in my angular .catch block?

Libraries for selecting a date and time in ReactJS 15.4?

Currently need a Date and Time picker for a web application I’m working on. Its using React version 15.4, so I haven’t been able to find a suitable library online. Currently using DatePicker from material-ui, but I’m unable to select a time, and since it’s an old version of react I can’t find the documentation for it anywhere.

Any ideas? Thanks

Intellisense cannot find exported elements in closed modules (ES6)

I have .jsx files where I export my react components, when I want to import it from other files, the Intellisense cannot locate it to import it automatically, but when I have the file open there it does locate it for import.

Wrapper.jsx

export default function Wrapper({ children, classes }) {
    return (
        <div className={clsx('wrapper', classes || false)}>
            {children}
        </div>
    )
}

Header.jsx

export default function Header() {
        return (
            <header>
                //Here I would import Wrapper
            </header>
        )
    }

Wrapper file closed
enter image description here

enter image description here

Wrapper file open
enter image description here

enter image description here

Any configuration that I have to do? It is annoying to open the files to just import them automatically with Intellisense

How do I update my NavBar once a user is logged-in (from ‘log in’ to ‘profile’) using React & Firebase?

I’m new to Reactjs & Firebase, but I’ve managed to set up a signup/login system- now once the user logs in, I have them redirected back to the home page, but I want the nav bar to display ‘profile’ instead of the original ‘log in’. I know this is something to do with Conditional Rendering but I’m having trouble implementing it with Firebase.


NavBar.js

import { Link } from 'react-router-dom'

// import { AuthProvider, useAuth } from '../contexts/AuthContext'
// import firebase from 'firebase/compat/app';

const NavBar = () => {

    return (
        <header>
            <Link to = '/'>
                <img src = {require('../images/logo.png')} alt = 'logo'/>
            </Link>
            <div id = 'nav-pages'>
                <Link to='/contact'>contact</Link>
                <Link to='/about'>about</Link>
                {/* change this to a link to a profile page */}
                <Link to='/login'>log-in</Link>
            </div>
        </header>
    )
}

export default NavBar

LogIn.js

import React, { useRef, useState } from 'react'
import NavBar from '../components/NavBar'
import Footer from '../components/Footer'

import { Link, useNavigate } from 'react-router-dom';
import { AuthProvider, useAuth } from '../contexts/AuthContext'

// change to login css
import '../css/SignUp.css'

export default function Login(){

    const emailRef = useRef();
    const passwordRef = useRef();

    const { login } = useAuth();
    const [error, setError] = useState("");
    const [loading, setLoading] = useState(false);

    const navigate = useNavigate();

    async function handleSubmit(e){
        e.preventDefault();

        try {
            setError("");
            setLoading(true);
            await login(emailRef.current.value, passwordRef.current.value);
            navigate('/', {replace: true});
        } catch {
            setError('failed to sign in');
        }
        setLoading(false);
    }

    return (
        <>
            <NavBar/>
            
            <div id = 'signup'>
                <div id = 'card'>
                    <h2>log in</h2>
                    {error && <p id = 'error'>{error}</p>}
                    
                    <form onSubmit={handleSubmit} id='form'>
                        <form id='email'>
                            <p>email</p>
                            <input type='email' ref = {emailRef} required/>
                        </form>

                        <form id='password'>
                            <p>password</p>
                            <input type='password' ref = {passwordRef} required/>
                        </form>

                        <button type='submit' disabled={loading}>log in</button>
                    </form>
                </div>

                <p>need an account? <Link to='/signup'>Sign Up</Link></p>

            </div>
            
            <Footer/>
        </>
    )
}

AuthContext.js

import React, { useContext, useState, useEffect } from 'react'
import { auth } from '../firebase';


const AuthContext = React.createContext()

export function useAuth(){
    return useContext(AuthContext)
}

export function AuthProvider({ children }){

    const [currentUser, setCurrentUser] = useState();
    const [loading, setLoading] = useState(true);

    function signup(email, password){
        return auth.createUserWithEmailAndPassword(email, password)
    }

    function login(email, password){
        return auth.signInWithEmailAndPassword(email,password)
    }

    useEffect(() => {
        const unsubscribe = auth.onAuthStateChanged(user => {
            setCurrentUser(user)
            setLoading(false)
        })

        return unsubscribe
    }, [])

    const value = {
        currentUser,
        login,
        signup,
    }

    return (
        <AuthContext.Provider value={value}>
            {!loading && children}
        </AuthContext.Provider>
    );
}

How can I show page elements by clicking on button?

First I’ll show my code

const mainButton = document.getElementById("start__button").addEventListener("click", function(event){
    event.target.parentNode.removeChild(event.target);
});

By clicking button, I want it to disappear and then appear new elements on page like navbar etc. The problem is I can’t handle it at this point and I need some help 😛

Why won’t my variable increment everytime I run the program?

This is a game where the player plays against the computer in a rock paper scissors game. I am trying to make the computer score or player score go up depending on which one wins. But it does not increment when I try to run it. I am new to functions and returning values so I do not really understand it.

// Declaring variables
let playerScore = 0;
let computerScore = 0;


// Gives a random value from the array  
function computerPlay(){
    var things = ['rock', 'paper', 'scissors'];
    var random = things[Math.floor(Math.random()*things.length)];
    console.log('The computer chose: ' + random);
    return random;
}

    // plays a round of the game
function playRound(playerSelection, computerSelection){

    if(playerSelection === computerSelection){
        console.log("tie");
    }
    else if(playerSelection === "rock" && computerSelection === "paper"){
        console.log("YOU LOSE");
        computerWin();
    }
    else if(playerSelection === "rock" && computerSelection === "scissors"){
        console.log("YOU WIN");
        playerWin();   
    }
    else if(playerSelection === "paper" && computerSelection === "rock"){
        console.log("YOU WIN");
        playerWin();
    }
    else if(playerSelection === "paper" && computerSelection === "scissors"){
        console.log("YOU LOSE");
        computerWin();
    }
    else if(playerSelection === "scissors" && computerSelection === "paper"){
        console.log("YOU WIN");
        playerWin();
    }
    else{
        console.log("YOU LOSE");
        computerWin();
    }
}

function playerWin(){
    ++playerScore;
    console.log("Player Score is " + playerScore);
}


function computerWin(){
   ++computerScore;
   console.log("Computer Score is " + computerScore)

}

// Call functions

let chooseWord = "Choose ";
let playerSelection = prompt(chooseWord);
console.log(playerSelection.toLowerCase());
let computerSelection = computerPlay();
computerSelection.toLowerCase();

playRound(playerSelection, computerSelection);
computerWin();
playerWin();