2018-07-06 18:15:15 +00:00
|
|
|
<template>
|
2019-08-03 19:03:45 +00:00
|
|
|
<div id="viewport" :class="viewportClasses" role="tablist">
|
2019-08-05 14:35:53 +00:00
|
|
|
<Sidebar :networks="networks" :active-channel="activeChannel" :overlay="$refs.overlay" />
|
|
|
|
<div id="sidebar-overlay" ref="overlay" @click="$root.setSidebar(false)" />
|
2018-07-06 18:15:15 +00:00
|
|
|
<article id="windows">
|
2018-07-08 13:42:54 +00:00
|
|
|
<Chat
|
|
|
|
v-if="activeChannel"
|
|
|
|
:network="activeChannel.network"
|
2019-03-01 14:18:16 +00:00
|
|
|
:channel="activeChannel.channel"
|
|
|
|
/>
|
2019-08-03 19:03:45 +00:00
|
|
|
<component :is="$store.state.activeWindow" ref="window" />
|
2018-07-06 18:15:15 +00:00
|
|
|
</article>
|
2019-09-20 18:10:48 +00:00
|
|
|
<ImageViewer ref="imageViewer" />
|
2018-07-06 18:15:15 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-20 08:36:55 +00:00
|
|
|
const throttle = require("lodash/throttle");
|
2018-08-31 18:15:46 +00:00
|
|
|
|
2019-02-22 14:21:32 +00:00
|
|
|
import Sidebar from "./Sidebar.vue";
|
2018-07-12 19:24:35 +00:00
|
|
|
import NetworkList from "./NetworkList.vue";
|
2018-07-08 10:50:11 +00:00
|
|
|
import Chat from "./Chat.vue";
|
2019-09-20 18:10:48 +00:00
|
|
|
import ImageViewer from "./ImageViewer.vue";
|
2019-02-18 09:18:32 +00:00
|
|
|
import SignIn from "./Windows/SignIn.vue";
|
2019-02-20 09:10:18 +00:00
|
|
|
import Settings from "./Windows/Settings.vue";
|
2019-03-01 13:29:00 +00:00
|
|
|
import NetworkEdit from "./Windows/NetworkEdit.vue";
|
|
|
|
import Connect from "./Windows/Connect.vue";
|
2019-02-20 15:01:33 +00:00
|
|
|
import Help from "./Windows/Help.vue";
|
2019-02-20 15:09:44 +00:00
|
|
|
import Changelog from "./Windows/Changelog.vue";
|
2018-07-06 18:15:15 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "App",
|
|
|
|
components: {
|
2019-02-22 14:21:32 +00:00
|
|
|
Sidebar,
|
2018-07-12 19:24:35 +00:00
|
|
|
NetworkList,
|
2019-09-20 18:10:48 +00:00
|
|
|
ImageViewer,
|
2018-07-08 10:50:11 +00:00
|
|
|
Chat,
|
2019-02-18 09:18:32 +00:00
|
|
|
SignIn,
|
2019-02-20 09:10:18 +00:00
|
|
|
Settings,
|
2019-03-01 13:29:00 +00:00
|
|
|
NetworkEdit,
|
|
|
|
Connect,
|
2019-02-20 15:01:33 +00:00
|
|
|
Help,
|
2019-02-20 15:09:44 +00:00
|
|
|
Changelog,
|
2018-07-06 18:15:15 +00:00
|
|
|
},
|
|
|
|
props: {
|
2019-02-18 09:18:32 +00:00
|
|
|
activeWindow: String,
|
2018-07-06 18:15:15 +00:00
|
|
|
activeChannel: Object,
|
|
|
|
networks: Array,
|
|
|
|
},
|
2019-04-13 20:44:04 +00:00
|
|
|
computed: {
|
|
|
|
viewportClasses() {
|
|
|
|
return {
|
2019-08-03 19:03:45 +00:00
|
|
|
notified: this.$store.state.isNotified,
|
2019-04-13 20:44:04 +00:00
|
|
|
"menu-open": this.$store.state.sidebarOpen,
|
2019-08-05 12:24:44 +00:00
|
|
|
"menu-dragging": this.$store.state.sidebarDragging,
|
2019-04-13 20:44:04 +00:00
|
|
|
"userlist-open": this.$store.state.userlistOpen,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
2018-08-31 18:15:46 +00:00
|
|
|
mounted() {
|
|
|
|
// Make a single throttled resize listener available to all components
|
|
|
|
this.debouncedResize = throttle(() => {
|
2018-08-31 18:37:39 +00:00
|
|
|
this.$root.$emit("resize");
|
2018-08-31 18:15:46 +00:00
|
|
|
}, 100);
|
|
|
|
|
|
|
|
window.addEventListener("resize", this.debouncedResize, {passive: true});
|
2018-09-12 17:14:45 +00:00
|
|
|
|
|
|
|
// Emit a daychange event every time the day changes so date markers know when to update themselves
|
|
|
|
const emitDayChange = () => {
|
|
|
|
this.$root.$emit("daychange");
|
|
|
|
// This should always be 24h later but re-computing exact value just in case
|
|
|
|
this.dayChangeTimeout = setTimeout(emitDayChange, this.msUntilNextDay());
|
|
|
|
};
|
|
|
|
|
|
|
|
this.dayChangeTimeout = setTimeout(emitDayChange, this.msUntilNextDay());
|
2018-08-31 18:15:46 +00:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener("resize", this.debouncedResize);
|
2018-09-12 17:14:45 +00:00
|
|
|
clearTimeout(this.dayChangeTimeout);
|
2018-08-31 18:15:46 +00:00
|
|
|
},
|
2018-08-31 18:37:39 +00:00
|
|
|
methods: {
|
|
|
|
isPublic: () => document.body.classList.contains("public"),
|
2018-09-12 17:14:45 +00:00
|
|
|
msUntilNextDay() {
|
|
|
|
// Compute how many milliseconds are remaining until the next day starts
|
2018-09-20 07:50:00 +00:00
|
|
|
const today = new Date();
|
|
|
|
const tommorow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
|
|
|
|
|
|
|
|
return tommorow - today;
|
2018-09-12 17:14:45 +00:00
|
|
|
},
|
2018-08-31 18:37:39 +00:00
|
|
|
},
|
2018-07-06 18:15:15 +00:00
|
|
|
};
|
|
|
|
</script>
|