diff --git a/client/components/App.vue b/client/components/App.vue index 8af3f566..f2ac5c4d 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -3,12 +3,7 @@ @@ -18,29 +13,13 @@ const throttle = require("lodash/throttle"); import Sidebar from "./Sidebar.vue"; -import NetworkList from "./NetworkList.vue"; -import Chat from "./Chat.vue"; import ImageViewer from "./ImageViewer.vue"; -import SignIn from "./Windows/SignIn.vue"; -import Settings from "./Windows/Settings.vue"; -import NetworkEdit from "./Windows/NetworkEdit.vue"; -import Connect from "./Windows/Connect.vue"; -import Help from "./Windows/Help.vue"; -import Changelog from "./Windows/Changelog.vue"; export default { name: "App", components: { Sidebar, - NetworkList, ImageViewer, - Chat, - SignIn, - Settings, - NetworkEdit, - Connect, - Help, - Changelog, }, props: { activeWindow: String, diff --git a/client/components/ChannelWrapper.vue b/client/components/ChannelWrapper.vue index 3d5ec16f..feb62695 100644 --- a/client/components/ChannelWrapper.vue +++ b/client/components/ChannelWrapper.vue @@ -23,6 +23,7 @@ :aria-selected="activeChannel && channel === activeChannel.channel" :style="closed ? {transition: 'none', opacity: 0.4} : null" role="tab" + @click="click" > @@ -80,6 +81,11 @@ export default { return this.channel.name; }, + click() { + // TODO: Find out why this sometimes throws `uncaught exception: Object` + this.$router.push("chan-" + this.channel.id); + this.$root.closeSidebarIfNeeded(); + }, }, }; diff --git a/client/components/Chat.vue b/client/components/Chat.vue index ec73fd3b..8a060172 100644 --- a/client/components/Chat.vue +++ b/client/components/Chat.vue @@ -133,7 +133,38 @@ export default { return undefined; }, }, + watch: { + channel(_, previousChannel) { + this.channelChanged(previousChannel); + }, + }, + mounted() { + this.channelChanged(); + }, methods: { + channelChanged(previousChannel) { + // Triggered when active channel is set or changed + + if (previousChannel) { + this.$root.switchOutOfChannel(previousChannel); + } + + this.channel.highlight = 0; + this.channel.unread = 0; + + this.$store.commit("activeWindow", null); + socket.emit("open", this.channel.id); + + if (this.channel.usersOutdated) { + this.channel.usersOutdated = false; + + socket.emit("names", { + target: this.channel.id, + }); + } + + this.$root.synchronizeNotifiedState(); + }, hideUserVisibleError() { this.$root.currentUserVisibleError = null; }, diff --git a/client/components/RoutedChat.vue b/client/components/RoutedChat.vue new file mode 100644 index 00000000..a9d22dd3 --- /dev/null +++ b/client/components/RoutedChat.vue @@ -0,0 +1,35 @@ + + + diff --git a/client/components/Sidebar.vue b/client/components/Sidebar.vue index c3e5455e..389d671c 100644 --- a/client/components/Sidebar.vue +++ b/client/components/Sidebar.vue @@ -25,6 +25,7 @@ role="tab" aria-controls="sign-in" :aria-selected="$store.state.activeWindow === 'SignIn'" + @click="navigate('sign-in')" />