Sample Code
/** Testing create/delete */
function createAndDelete() {
// ChatManager.createDirectMessage(...) just returns the result from kitty.createChannel(...)
const channel = await ChatManager.createDirectMessage([friendUsername]);
if (!channel) {
return;
}
// ...
const user = await ChatManager.getCurrentUser();
const statusResult = await kitty.getUserIsChannelMember({
channel,
user,
});
if (isSuccess<GetUserIsChannelMemberSucceededResult>(statusResult)) {
console.log('Is Member: ', statusResult.isMember); // Outputs: Is Member: true
}
const result = await kitty.leaveChannel({
channel,
});
if (isSuccess<LeftChannelResult>(result)) {
console.log('Left channel!'); // No output
} else if (isFailure(result)) {
console.error('Could not leave channel', result.error); // No output
}
// ... This is unreachable
}
Leaving a channel seems to result in NotAChannelMemberError
being thrown. Looking at the error message, I can clearly see my user in the list of members. Calling kitty.getUserIsChannelMember(...)
also confirms this.
The message also shows that the _actions
property lacks the leave
property. Looking at the source code, this might be part of why the error is thrown, though I’m not sure why leave
is missing.
EDIT: Running “Delete Channel Membership” from the REST API returns with an InternalServerError
.