Created
October 10, 2021 16:41
-
-
Save hieptl/ec5164216aa69d280d5bc4f64b153281 to your computer and use it in GitHub Desktop.
Home.js - Search Data - React Native Gifted Chat App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
const searchUsers = () => { | |
if (cometChat) { | |
const limit = 30; | |
const usersRequestBuilder = new cometChat.UsersRequestBuilder().setLimit(limit); | |
const usersRequest = keyword ? usersRequestBuilder.setSearchKeyword(keyword).build() : usersRequestBuilder.build(); | |
usersRequest.fetchNext().then( | |
userList => { | |
/* userList will be the list of User class. */ | |
/* retrived list can be used to display contact list. */ | |
setData(() => userList); | |
}, | |
error => { | |
} | |
); | |
} | |
}; | |
const searchGroups = () => { | |
const limit = 30; | |
const groupRequestBuilder = new cometChat.GroupsRequestBuilder().setLimit(limit); | |
const groupsRequest = keyword ? groupRequestBuilder.setSearchKeyword(keyword).build() : groupRequestBuilder.build(); | |
groupsRequest.fetchNext().then( | |
groupList => { | |
/* groupList will be the list of Group class */ | |
/* you can display the list of groups available using groupList */ | |
setData(() => groupList); | |
}, | |
error => { | |
} | |
); | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment