React Native useEffect works on file save

I am developing a video chat app using react-native-voximplant, everything works, but when the app loads first time, the login functionality is happening inside the useEffect. So, the problem is, when my HomeScreen mounts, the useEffects’ should fire and I should get logged in voximplant sdk and now if I tap on call icon, the following is shown in the console:

When HomeScreen mounts:

LOG Client: emit: no handlers for event: AuthResult
LOG Error while trying to login to voximplant:  {"code": 491, "name": "AuthResult", "result": false}
LOG Client: emit: no handlers for event: ConnectionEstablished

Now when I tap on call to make a call:

// after a second...

WARN Possible Unhandled Promise Rejection (id: 0):
"NOT_LOGGED_IN"

Now when I hit save (ctrl+s), I get logged in and now if I make a call, it works! I don’t know what I am doing wrong here. Is something wrong with useEffect or I’m doing something wrong?

The HomeScreen code:

import {Voximplant} from 'react-native-voximplant';

const HomeScreen = () => {
  const voximplant = Voximplant.getInstance();

  useEffect(() => {
    const signInToVoximplant = async () => {
      try {
        const fqUsername = '...'; // credentials are correct, don't worry about them.
        const password = '...';
        await voximplant.login(fqUsername, password);
      } catch (error) {
        console.log('Error while trying to login to voximplant: ', error);
      }
    };
    signInToVoximplant();
  }, []);

  useEffect(() => {
    const connect = async () => {
      const status = await voximplant.getClientState();
      if (status === Voximplant.ClientState.DISCONNECTED) {
        await voximplant.connect();
      } else if (status === Voximplant.ClientState.LOGGED_IN) {
        console.log('[INFO] VOXIMPLANT CONNECTED');
        return;
      }
    };
      connect();
    }, []);
  }
  
  return ...

The call will only work if I hit ctrl+s i.e. save the file, otherwise it will throw Unhandled Promise rejection... because it is not logged in, however I have written/provided the login inside the useEffect.

display sticky div if within viewport

I am basing my code off of this thread Displaying a div once its within the viewport

I have a parent div that is half way down the page, within that parent div I want to display a sticky footer div, but only when viewport is showing parent div. I have tried 4 different tutorials so far with no luck.

page structure is this

HEADER

HERO

CONTENT RIGHT-SIDE(id=”wrap-vs”)

CONTENT-FULL-WIDTH

FOOTER

So when RIGHT-SIDE is within view, I want to display a sticky div within it, you can’t see RIGHT-SIDE when page loads, you need to scroll down to it, also when we are below it, I want to sticky div to go away.

This is my code so far

//HTML
<div id="wrap-vs">
    <div class="tabs">
        right-side content sticky div
    </div>
</div>
 
//CSS
#wrap-vs{
    height: 100%;
    background-color: yellow;
}

.tabs {
    position: fixed;
    bottom: 0;
}

// JS

var targetdiv = document.querySelector('.tabs');
console.log(targetdiv);
targetdiv.style.display = "none";

function CheckIfVisible(elem, targetdiv){
        
        var ElemPos = elem.getBoundingClientRect().top;
        targetdiv.style.display = (ElemPos > 0 && ElemPos < document.body.parentNode.offsetHeight)?"block":"none";
    }
    
    window.addEventListener("onscroll", function(){
        var elem = document.querySelector('#wrap-vs');
        
        CheckIfVisible(elem, targetdiv);
    });
    

866-517-1058 Chase Bank customer service

Chase customer service is available at five different phone numbers. Their general customer support number is 866-517-1058. You can contact this number 24 hours a day, seven days a week. The average waiting time is 20 minutes. It is best to call at 9:05 am.

To get targeted help, you can contact numbers specifically for mobile banking, freedom cards, and lost cards. You can also find a separate number for international customer service. Calling a targeted help number will increase the chances of resolving your problem fast.

For mobile banking concerns, call 866-517-1058. This number has a hold time of about 20 minutes. It is preferable to call this number at 10:15 a.m. To quickly get a live person, dial 0.

Contact 866-517-1058 for freedom card concerns. It takes 50 minutes or even longer for someone to answer the phone. This can be a real pain, so try to call at 10:15 a.m. for the shortest possible hold time.

Contact866-517-1058 for lost cards. On average, the waiting time is 20 minutes. Calling this number is free of charge, and it is most time-efficient to dial it at 9:45 a.m.

International callers can contact 866-517-1058. At the time of writing, the hold time was 20 minutes. This number is not toll-free. It is best to call it at 10:15 a.m.

how do I delay the exiting from a function in javaScript? [duplicate]

my problem is that I need to wait a bit before returning the value.
the function is returning the variable x before the var updates (or at least I think that it’s the problem).

var x; //now it's undefined
  con.connect(function(err) {
    if (err) throw err;
    con.query("SELECT * FROM usrs", function (err, result) {
      if (err) throw err;
      x= result; //trying to update x
  });
});
  return x; //returns undefined(because it doesn't have enough time to change so it stays like it was at the beginning)

defaultExpandAllRows antd table react with fetch not working

i use Ant Design table as ui

what’s wrong with my code, table using local data can be automatically expanded, but it’s different for the results from fetch can’t automatically expand with the same code

what am i missing here?

i can’t explain with good language, look at my sandbox https://codesandbox.io/s/defaultexpandallrows-antd-table-f1okb

this code will automatically expand

  const data = [
  {
    key: 55,
    name: "John Brown sr.",
    xchildren: [
      { key: 73, address: "New York No. 2 Lake Park" },
      { key: 46, address: "New York No. 2 Lake Park" },
    ],
  },
];

 <Table
      dataSource={data}
      defaultExpandAllRows={true}
      key={data.key}
      expandable={{
        expandedRowRender: (record) => (
          <Table pagination={false} dataSource={record.xchildren}>
            <Column title="Address" dataIndex="address" key="address" />
          </Table>
        ),
      }}
    >
      <Column title="name" dataIndex="name" key="key" />
    </Table>

this will not automatically expand table

fetch = () => {
    fetch(`https://api.jsonbin.io/b/61e6fd62ba87c130e3eaa7ef`)
      .then((res) => res.json())
      .then((data) => {
        console.log(data);
        this.setState({
          dataJSON: data,
        });
      });
  };

  <Table
           <Table
      dataSource={dataJSON}
      defaultExpandAllRows={true}
      key={data.key}
      expandable={{
        expandedRowRender: (record) => (
          <Table dataSource={record.xchildren}>
            <Column
              pagination={false}
              title="Address"
              dataIndex="address"
              key="address"
            />
          </Table>
        ),
      }}
    >
      <Column title="name" dataIndex="name" key="key" />
    </Table>

full code

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import { Table,version } from "antd";
const { Column } = Table;

const data = [
  {
    key: 55,
    name: "John Brown sr.",
    xchildren: [
      { key: 73, address: "New York No. 2 Lake Park" },
      { key: 46, address: "New York No. 2 Lake Park" },
    ],
  },
];

class App extends React.Component {
  state = {
    dataJSON: [],
  };

  componentDidMount() {
    const { pagination } = this.state;
    this.fetch({ pagination });
  }

  fetch = () => {
    fetch(`https://api.jsonbin.io/b/61e6fd62ba87c130e3eaa7ef`)
      .then((res) => res.json())
      .then((data) => {
        console.log(data);
        this.setState({
          dataJSON: data,
        });
      });
  };

  render() {
    const { dataJSON } = this.state;
    return (
      <>
      antd version: {version}
      <p>will automatically expand</p>
        <Table
          dataSource={data}
          defaultExpandAllRows={true}
          key={data.key}
          expandable={{
            expandedRowRender: (record) => (
              <Table pagination={false} dataSource={record.xchildren}>
                <Column title="Address" dataIndex="address" key="address" />
              </Table>
            ),
          }}
        >
          <Column title="name" dataIndex="name" key="key" />
        </Table>
        <hr />
        <p> will not automatically expand</p>
        <Table
          dataSource={dataJSON}
          defaultExpandAllRows={true}
          key={data.key}
          expandable={{
            expandedRowRender: (record) => (
              <Table dataSource={record.xchildren}>
                <Column
                  pagination={false}
                  title="Address"
                  dataIndex="address"
                  key="address"
                />
              </Table>
            ),
          }}
        >
          <Column title="name" dataIndex="name" key="key" />
        </Table>
      </>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("container"));

thank you…

Error: querySrv ENOTFOUND _mongodb._tcp.cluster0.kspub.mongodb.net

my web app cannot connect to mongo dB atlas and it shows me the following error

Failed to connect to the database :Error: querySrv ENOTFOUND _mongodb._tcp.cluster0.kspub.mongodb.net
2022-01-18T16:58:59.817138+00:00 app[web.1]: (node:34) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.cluster0.kspub.mongodb.net
2022-01-18T16:58:59.817138+00:00 app[web.1]: at QueryReqWrap.onresolve [as oncomplete] (dns.js:210:19)
2022-01-18T16:58:59.817139+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)

error message

even though it works locally and connects to the database, here is my code
https://github.com/yara121/mern-app/blob/main/server/src/app.js

Why does my website keep showing old index.html, style.css, app.js…?

I have a problem that I can’t solve. I’m new to web-developing, and I coded my first web-site, bought a domain and hosting, and added my files to the public.html folder.

Whenever I change the code, either in css or js and delete the previous files in the public.html folder and then add new ones under the same name with which the code was changed, when I load the site, either by phone or desktop the site looks and all elements remain the same that I haven’t changed the code at all, if I change the names of the html, css and js files, I link them and insert them that way, it only shows me a list of files in the public.html folder. The only time the code update works is when I open the site in incognito mode for browsers.

My assumption is that there are some problems with cookies and cached data, but even when I delete them in browser, the code is not updated but the site uses old files.

Does anyone know some solution to my problem, otherwise I use domain and hosting from hostinger and I haven’t changed any settings in domen and hosting since I bought it.

Thank you all.

How to read Blob synchronously in Javascript?

I’m writing a chrome extension to intercept WebSocket traffic, by hooking the function WebSocket.send, like:

var _send = WSObject.send
WSObject.send = function (data) {
    arguments[0] = my_hook_function(data)
    _send.apply(this, arguments)
}

function my_hook_function(data) {
    // how to read the data here synchronously?
    return data
}

The my_hook_function should be synchronous. The type of data is Blob, I can’t find a synchronous API for reading the Blob. Google says there is FileReaderSync but I tried in console and this class does not exist.

How to solve it?

Nextjs: static class / use function

I want to create tools class/function in nextjs

I have 2 ways for this.

With static class:

class Tools {
    static titleCase(value: string) {
        return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
    }
}

export default Tools

With use function:

export default function Tools(){
    function titleCase(value: string) {
        return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
    }

    return { titleCase }
}

And here is my question:

1- Which is better?

2- What is difference between these?

how to access object data within object

I have this:

const paymentIntents = await stripe.paymentIntents.list({
    stripeAccount: stripe_account
});

and it returns:

object: 'list',
  data: [
    {
      id: 'pi_...',
      object: 'payment_intent',
      amount: 2500,

now I have two problems. 1. I need to access amount. and 2. there is going to be dozens of records being returned, so I need to loop through all the results and actually add up the amounts. here’s what I’ve tried so far:

console.log(paymentIntents.amount)
console.log(paymentIntents.data.amount)

neither of those worked. and i wouldn’t even know how to loop thorugh all those results. How can i do this?

Best way to update all documents in a collection in mongo?

Basically, I want to check a schedule field in every document, and if Date.now() falls within the bounds of the schedule, I want to set isActive to true.

{

schedule: {
    start: (Date object),
    end: (Date object)
},
isActive: false

}

That in itself is simple, but my issue is that this collection can potentially have hundreds of thousands of documents. I also need this to run every 30 minutes using cron.

Is there any way to efficiently do this without totally locking up my application and/or database every 30 minutes for however long it takes?

Do I need to call save() on each document individually or is there a way I can save all of them at once?

Requesting guidance on user profiles and personal MongoDB collections

I am working with Node/express/javascript/mongoDB.

   My application is one where users log in, POST key/value pairs to a REST api, and the saved data is to be shared with other users of their choice.
    As of now I have the server & front end communicating so users can POST data to a local mongodb. My next step is new users/logins, which I will approach with Passport and a local strategy.
Where I need guidance:
    Let’s say I have 20 users logged in, they all add their own list of items to the db in varying quantities, 10 entries give or take. HOW do I enable their document collections to stay private to their user profile in the overall database AND then be shared with select people to view as in a private group? (is namespacing involved here?)
    I would appreciate advice on if I am proceeding in the right direction and some opinions of popular approach to this kind of thing.
In a nutshell: user logs in, makes a list of things (saved to mongodb), user invites X amount of friends to view their list.

TypeError Next.js GetStaticProps

I have the following error in my Next.js project

error - pagespost[slug].js (30:38) @ getStaticProps
TypeError: (0 , _services__WEBPACK_IMPORTED_MODULE_2__.getPostDetails) is not a function

Can anyone help me to solve this?

export async function getStaticProps({ params }) {
    const data = await getPostDetails(params.slug);
    return {
        props: {
            post: data,
        },
    };
}

export async function getStaticPaths() {
    const posts = await getPosts();
    return {
        paths: posts.map(({ node: { slug } }) => ({ params: { slug } })),
        fallback: false,
    };
}