Join channel UI shows if channel is not joined but network is found
This commit is contained in:
parent
09d374f2b8
commit
92152af2d2
|
@ -53,8 +53,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
inputChannel: "",
|
||||
inputPassword: "",
|
||||
inputChannel: this.$route.query.channel ? this.$route.query.channel : "",
|
||||
inputPassword: this.$route.query.password ? this.$route.query.password : "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -239,6 +239,10 @@ export default {
|
|||
searchText() {
|
||||
this.setActiveSearchItem();
|
||||
},
|
||||
"this.$route.query.channel"(value) {
|
||||
const activeNetwork = this.$store.state.activeChannel.network;
|
||||
activeNetwork.isJoinChannelShown = true;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
Mousetrap.bind("alt+shift+right", this.expandNetwork);
|
||||
|
|
|
@ -90,17 +90,46 @@ router.beforeEach((to, from, next) => {
|
|||
|
||||
// If trying to navigate to an invalid channel,
|
||||
// we attempt to either open a connection dialog to the network
|
||||
// or populate the Join Channel field in the exiting network.
|
||||
if (
|
||||
to.name === "RoutedChat" &&
|
||||
!store.getters.findChannelByName(to.params.networkHost, to.params.channelName)
|
||||
) {
|
||||
// or populate the Join Channel field in the existing network.
|
||||
if (to.name === "RoutedChat") {
|
||||
let channel = to.hash;
|
||||
const {networkHost, channelName} = to.params;
|
||||
|
||||
// If the channel isn't provided as the hash, check if it's provided as the next param
|
||||
if (!channel) {
|
||||
if (channelName) {
|
||||
channel = channelName;
|
||||
}
|
||||
}
|
||||
if (store.getters.findChannelByName(networkHost, channel)) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
const existingNetwork = store.state.networks.find(
|
||||
(network) => network.host === to.params.networkHost
|
||||
);
|
||||
|
||||
if (existingNetwork) {
|
||||
// Join UI
|
||||
// Join Channel UI
|
||||
|
||||
const activeChannel = store.state.activeChannel;
|
||||
// if the active channel is in the network, send the user back to that channel, else to the lobby
|
||||
if (activeChannel && activeChannel.network.uuid === existingNetwork.uuid) {
|
||||
next({
|
||||
path: `/${to.params.networkHost}/${encodeURIComponent(
|
||||
activeChannel.channel.name
|
||||
)}`,
|
||||
query: {channel},
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
next({
|
||||
path: `/${to.params.networkHost}/${existingNetwork.name}`,
|
||||
query: {channel},
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Connect UI
|
||||
next({
|
||||
|
|
|
@ -130,6 +130,10 @@ const store = new Vuex.Store({
|
|||
return null;
|
||||
},
|
||||
findChannelByName: (state) => (networkHost, channelName) => {
|
||||
if (!networkHost || !channelName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (const network of state.networks) {
|
||||
if (network.host.toLowerCase() === networkHost.toLowerCase()) {
|
||||
for (const channel of network.channels) {
|
||||
|
|
Loading…
Reference in New Issue