How to properly leave a channel and join another channel from client-side? (or leave topic -> join topic)

I have a messenger app set up where there is a list of chat rooms. When someone clicks one from the list, the site removes the original conversation and loads up the new conversation. In Phoenix, I want the user to leave the original channel/topic and then join the new channel/topic. The problem I’ve discovered, is that when the user sends a message in the new conversation, it ends up going to the previous conversation as well. It doesn’t seem like convchannel.leave() is working. Here is my client-side Javascript:

let socket = new Phoenix.Socket("wss://app.example.com/socket", {params: () => {return {token: window.dbchattoken, anses: window.userid, at: window.at};},});
socket.connect();

let convchannel = null; # conversation channel doesn't exist on page load until user clicks first room.
let convpresence = null;

function loadConversation(roomid) { # when a user clicks on a room, load up conversation.
  # ... remove old conversation / load up new conversation on the page.

  if(convchannel !== null) { # if convchannel is initialized, leave existing room before joining the new one.
    console.log("leave channel");
    convchannel.leave();
  }
  convchannel = socket.channel("conv:"+roomid+"", {});
  convpresence = new Phoenix.Presence(convchannel);
  convchannel.join()
    .receive("ok", resp => { console.log("Joined conversation successfully", resp); })
    .receive("error", resp => { console.log("Error ", resp); })

  convchannel.on("receiveMessage", (payload) => {console.log("receive message: ", payload); displayMessage(roomid,payload); });
}

I’m still sort of new to Phoenix, so I’m wondering if this is supposed to be handled in a different manner.

Thanks

Sorry, nevermind. After banging my head against the wall for hours, I found that the subtle issue was related to Microsoft Edge. Apparently, Javascript runs a little differently on Edge vs Chrome, so a small error elsewhere in my script was throwing off Phoenix. Made it even more confusing since the “leave room” event was refusing to run only some of the time (only when I tested on Edge), which threw off everything in Chrome too…