Last active
October 27, 2021 10:09
-
-
Save hieptl/e9cb49babe799b3e60498d3d23aa3106 to your computer and use it in GitHub Desktop.
ManageGroup.tsx - Delete Group & Leave Group - 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 handleDeleteGroup = () => { | |
if (selectedConversation && selectedConversation.name && selectedConversation.guid) { | |
setIsLoading(true); | |
cometChat.deleteGroup(selectedConversation.guid).then( | |
(response: any) => { | |
setIsLoading(false); | |
alert(`${selectedConversation.name} was deleted successfully`); | |
history.push('/'); | |
}, | |
(error: any) => { | |
setIsLoading(false); | |
alert(`Failure to delete ${selectedConversation.name}`) | |
} | |
); | |
} | |
}; | |
const deleteGroup = () => { | |
const shouldDeleteGroup = window.confirm(`Do you want to delete group ${selectedConversation.name}`); | |
if (shouldDeleteGroup) { | |
handleDeleteGroup(); | |
} | |
}; | |
const handleLeaveGroup = () => { | |
if (selectedConversation && selectedConversation.guid && selectedConversation.name) { | |
setIsLoading(true); | |
cometChat.leaveGroup(selectedConversation.guid).then( | |
(hasLeft: any) => { | |
setIsLoading(false); | |
alert(`${user.name} has left the group ${selectedConversation.name}`); | |
history.push('/'); | |
}, (error: any) => { | |
} | |
); | |
} | |
}; | |
const leaveGroup = () => { | |
const shouldLeaveGroup = window.confirm(`Do you want to leave group ${selectedConversation.name}`); | |
if (shouldLeaveGroup) { | |
handleLeaveGroup(); | |
} | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment