prose-im/prose-core-client

joinRoom method should not throw an error if room is already joined

Closed this issue · 2 comments

In the app, when trying to join a channel that’s already joined, the joinRoom method throws an error stating that the room is already joined.

While I understand the rationale, this error could be silenced and the method could return the same result as if the room was just joined, since that would help implementing apps to hold less conditional logic on checking if the room is already joined or not.

In some cases where there are a lot of channels the user might try to use the Add Channel modal to join a channel that they are already member of, instead of finding the channel in their sidebar. It makes sense to consider a room join in a joined room as a success then.

I could throw a custom error that you could evaluate. I guess you'd want to at least select the room in question? What do you think?

Or could you maybe add an (optional?) argument to ignore exist errors? Or an enum-based error if that's possible, but JS errors are crap honestly, most often people evaluate the toString() output and check if the error matches a substring, which is total crap.