Merge pull request #90 from Fab1en/features/fabien/join-channel-on-reload
[dev] Reflect channel change in URL
This commit is contained in:
commit
c44523b78a
20
app/index.js
20
app/index.js
|
@ -792,6 +792,26 @@ class GlobalBindings {
|
||||||
this.requestMove = (user, channel) => {
|
this.requestMove = (user, channel) => {
|
||||||
if (this.connected()) {
|
if (this.connected()) {
|
||||||
user.model.setChannel(channel.model)
|
user.model.setChannel(channel.model)
|
||||||
|
|
||||||
|
let currentUrl = url.parse(document.location.href, true)
|
||||||
|
// delete search param so that query one can be taken into account
|
||||||
|
delete currentUrl.search
|
||||||
|
|
||||||
|
// get full channel path
|
||||||
|
if( channel.parent() ){ // in case this channel is not Root
|
||||||
|
let parent = channel.parent()
|
||||||
|
currentUrl.query.channelName = channel.name()
|
||||||
|
while( parent.parent() ){
|
||||||
|
currentUrl.query.channelName = parent.name() + '/' + currentUrl.query.channelName
|
||||||
|
parent = parent.parent()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// there is no channelName as we moved to Root
|
||||||
|
delete currentUrl.query.channelName
|
||||||
|
}
|
||||||
|
|
||||||
|
// reflect this change in URL
|
||||||
|
window.history.pushState(null, channel.name(), url.format(currentUrl))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue