[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.
This commit is contained in:
Fabien Quatravaux 2020-04-12 11:51:41 +02:00
parent 5640c6c108
commit eb8de9c2c2

View file

@ -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))
}
}