Skip to content

Instantly share code, notes, and snippets.

@hieptl
Last active October 27, 2021 10:13
Show Gist options
  • Save hieptl/46bb1d904c906c11e4c0313ad2e27390 to your computer and use it in GitHub Desktop.
Save hieptl/46bb1d904c906c11e4c0313ad2e27390 to your computer and use it in GitHub Desktop.
Home.tsx - Join Group, Select Item - Ionic Chat App
...
const joinGroup = (item: any) => {
if (item && item.guid && !item.hasJoined) {
setIsLoading(true);
const GUID = item.guid;
const password = "";
const groupType = cometChat.GROUP_TYPE.PUBLIC;
cometChat.joinGroup(GUID, groupType, password).then(
(group: any) => {
setIsLoading(false);
},
(error: any) => {
setIsLoading(false);
}
);
}
};
const selectItem = (item: any) => () => {
// if item is a group. Join the group if the user has not joined before.
if (item && item.guid && !item.hasJoined) {
joinGroup(item);
}
setSelectedConversation({ ...item, contactType: selectedType });
history.push('/chat');
};
const goToCreateGroupPage = () => {
history.push('/create-group');
};
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment