How to use the @cometchat-pro/react-native-chat.CometChat.UsersRequestBuilder function in @cometchat-pro/react-native-chat

To help you get started, we’ve selected a few @cometchat-pro/react-native-chat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cometchat-pro-samples / react-native-chat-app / chatApp / src / HomeScreen.js View on Github external
fetchUser() {
        console.log('Fetch user called.....')
        var limit = 30;
        var usersRequest = new CometChat.UsersRequestBuilder().setLimit(limit).build();
        usersRequest.fetchNext().then(
            userList => {
                if(userList.length >0){
                    CometChat.getUnreadMessageCountForAllUsers().then(array=>{
                        var unread = Object.keys(array);
                        if(unread.length > 0){
                            unread.map(uid =>{
                                var index = userList.findIndex(user=> user.uid == uid);
                                if(index != -1){
                                    userList[index].unreadCount = array[uid];
                                }
                            });
                        } 
                        this.setState({
                            users: userList,
                        });