From eb8de9c2c2fc3e0ea149944e49f42e15006d1eab Mon Sep 17 00:00:00 2001 From: Fabien Quatravaux Date: Sun, 12 Apr 2020 11:51:41 +0200 Subject: [PATCH] [dev] Reflect channel change in URL It means that if I go to a channel and refresh the page, I will be reconnected to this channel after refresh. --- app/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/index.js b/app/index.js index 15737e9..4d7f4f0 100644 --- a/app/index.js +++ b/app/index.js @@ -784,6 +784,11 @@ class GlobalBindings { this.requestMove = (user, channel) => { if (this.connected()) { user.model.setChannel(channel.model) + // reflect this change in URL + let currentUrl = url.parse(document.location.href, true) + currentUrl.query.channelName = channel.name() + delete currentUrl.search + window.history.pushState(null, channel.name(), url.format(currentUrl)) } }