prose-im/prose-core-client

createPublicChannel should join channel if the name already exists

Closed this issue · 3 comments

The JSDoc for createPublicChannel on the JS SDK says that: https://gist.github.com/nesium/f1c21dfb0d345b8c223017f418343a4e#file-prose_sdk_js-d-ts-L482

I'd expect that calling eg. createPublicChannel("support") where #support already exists, would let me join the channel, as the JSDoc states. However, I'm getting this error: A public channel with the chosen name exists already.

I admit that the documentation doesn't match the actual behavior. It is sometimes hard to design the API without seeing the actual UI. I've now changed my opinion a bit about the behavior and think that it could be confusing if you were thrown into an existing channel without any notice when you thought that you were creating a brand new channel instead.

From that POV I think Slack's interface makes total sense:

If we'd want to add a bit of convenience we could still add another button that would allow to join the existing channel.

What do you think? Change the documentation or the behavior of the method?

Sounds good! I'll also need a method to check if a channel already exists, returning eg. a boolean or JID.

Added Client::findPublicChannelByName

As the name suggests finds only public channels. Refs prose-im/prose-pod-system#4