Last active
October 27, 2021 10:13
-
-
Save hieptl/46bb1d904c906c11e4c0313ad2e27390 to your computer and use it in GitHub Desktop.
Home.tsx - Join Group, Select Item - Ionic 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 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