2018-07-08 10:50:11 +00:00
|
|
|
<template>
|
2019-08-13 21:24:34 +00:00
|
|
|
<div id="chat-container" class="window" :data-current-channel="channel.name">
|
2018-07-08 13:42:54 +00:00
|
|
|
<div
|
|
|
|
id="chat"
|
2018-07-09 10:44:12 +00:00
|
|
|
:data-id="channel.id"
|
2018-07-08 17:26:26 +00:00
|
|
|
:class="{
|
2019-11-03 18:05:19 +00:00
|
|
|
'hide-motd': !$store.state.settings.motd,
|
|
|
|
'colored-nicks': $store.state.settings.coloredNicks,
|
|
|
|
'show-seconds': $store.state.settings.showSeconds,
|
2019-02-25 05:38:13 +00:00
|
|
|
}"
|
|
|
|
>
|
2018-07-08 12:18:17 +00:00
|
|
|
<div
|
|
|
|
:id="'chan-' + channel.id"
|
|
|
|
:class="[channel.type, 'chan', 'active']"
|
|
|
|
:data-id="channel.id"
|
|
|
|
:data-type="channel.type"
|
|
|
|
:aria-label="channel.name"
|
2019-02-25 05:38:13 +00:00
|
|
|
role="tabpanel"
|
|
|
|
>
|
2018-07-08 12:18:17 +00:00
|
|
|
<div class="header">
|
2019-04-13 20:44:04 +00:00
|
|
|
<SidebarToggle />
|
2018-07-08 12:18:17 +00:00
|
|
|
<span class="title">{{ channel.name }}</span>
|
2019-08-11 13:59:06 +00:00
|
|
|
<div v-if="channel.editTopic === true" class="topic-container">
|
|
|
|
<input
|
|
|
|
:value="channel.topic"
|
|
|
|
class="topic-input"
|
|
|
|
placeholder="Set channel topic"
|
|
|
|
@keyup.enter="saveTopic"
|
|
|
|
@keyup.esc="channel.editTopic = false"
|
|
|
|
/>
|
|
|
|
<span aria-label="Save topic" class="save-topic" @click="saveTopic">
|
|
|
|
<span type="button" aria-label="Save topic"></span>
|
|
|
|
</span>
|
|
|
|
</div>
|
2019-08-03 10:09:55 +00:00
|
|
|
<span v-else :title="channel.topic" class="topic" @dblclick="editTopic"
|
2019-07-17 09:33:59 +00:00
|
|
|
><ParsedMessage
|
|
|
|
v-if="channel.topic"
|
|
|
|
:network="network"
|
|
|
|
:text="channel.topic"
|
2019-02-25 05:38:13 +00:00
|
|
|
/></span>
|
2019-11-09 22:21:34 +00:00
|
|
|
<button
|
|
|
|
class="menu"
|
|
|
|
aria-label="Open the context menu"
|
|
|
|
@click="openContextMenu"
|
|
|
|
/>
|
2018-07-08 12:18:17 +00:00
|
|
|
<span
|
|
|
|
v-if="channel.type === 'channel'"
|
|
|
|
class="rt-tooltip tooltipped tooltipped-w"
|
2019-02-25 05:38:13 +00:00
|
|
|
aria-label="Toggle user list"
|
|
|
|
>
|
2019-04-13 20:44:04 +00:00
|
|
|
<button
|
|
|
|
class="rt"
|
|
|
|
aria-label="Toggle user list"
|
2019-11-07 23:50:51 +00:00
|
|
|
@click="$store.commit('toggleUserlist')"
|
2019-04-13 20:44:04 +00:00
|
|
|
/>
|
2018-07-08 12:18:17 +00:00
|
|
|
</span>
|
2018-07-08 10:50:11 +00:00
|
|
|
</div>
|
2019-07-17 09:33:59 +00:00
|
|
|
<div v-if="channel.type === 'special'" class="chat-content">
|
2018-07-19 10:01:52 +00:00
|
|
|
<div class="chat">
|
|
|
|
<div class="messages">
|
|
|
|
<div class="msg">
|
2018-12-17 10:29:49 +00:00
|
|
|
<Component
|
2018-07-19 10:01:52 +00:00
|
|
|
:is="specialComponent"
|
2018-07-19 17:44:24 +00:00
|
|
|
:network="network"
|
2019-02-25 05:38:13 +00:00
|
|
|
:channel="channel"
|
|
|
|
/>
|
2018-07-19 10:01:52 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-07-10 09:16:24 +00:00
|
|
|
</div>
|
2019-07-17 09:33:59 +00:00
|
|
|
<div v-else class="chat-content">
|
2018-09-24 12:47:39 +00:00
|
|
|
<div
|
2019-07-17 09:33:59 +00:00
|
|
|
:class="[
|
|
|
|
'scroll-down tooltipped tooltipped-w tooltipped-no-touch',
|
|
|
|
{'scroll-down-shown': !channel.scrolledToBottom},
|
|
|
|
]"
|
2019-02-18 06:27:35 +00:00
|
|
|
aria-label="Jump to recent messages"
|
2019-02-25 05:38:13 +00:00
|
|
|
@click="$refs.messageList.jumpToBottom()"
|
|
|
|
>
|
2018-09-24 12:47:39 +00:00
|
|
|
<div class="scroll-down-arrow" />
|
|
|
|
</div>
|
2019-07-17 09:33:59 +00:00
|
|
|
<MessageList ref="messageList" :network="network" :channel="channel" />
|
|
|
|
<ChatUserList v-if="channel.type === 'channel'" :channel="channel" />
|
2018-07-08 10:50:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-31 10:43:21 +00:00
|
|
|
<div
|
2019-11-02 19:40:59 +00:00
|
|
|
v-if="this.$store.state.currentUserVisibleError"
|
2018-10-16 10:21:16 +00:00
|
|
|
id="user-visible-error"
|
2019-02-25 05:38:13 +00:00
|
|
|
@click="hideUserVisibleError"
|
2019-07-17 09:33:59 +00:00
|
|
|
>
|
2019-11-02 19:40:59 +00:00
|
|
|
{{ this.$store.state.currentUserVisibleError }}
|
2019-07-17 09:33:59 +00:00
|
|
|
</div>
|
2018-09-03 07:58:33 +00:00
|
|
|
<span id="upload-progressbar" />
|
2019-07-17 09:33:59 +00:00
|
|
|
<ChatInput :network="network" :channel="channel" />
|
2018-07-08 10:50:11 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-09 22:21:34 +00:00
|
|
|
import socket from "../js/socket";
|
|
|
|
import {generateChannelContextMenu} from "../js/helpers/contextMenu.js";
|
2018-07-12 08:41:40 +00:00
|
|
|
import ParsedMessage from "./ParsedMessage.vue";
|
2018-07-08 17:22:01 +00:00
|
|
|
import MessageList from "./MessageList.vue";
|
2018-07-08 13:42:54 +00:00
|
|
|
import ChatInput from "./ChatInput.vue";
|
2018-07-08 17:22:01 +00:00
|
|
|
import ChatUserList from "./ChatUserList.vue";
|
2019-04-13 20:44:04 +00:00
|
|
|
import SidebarToggle from "./SidebarToggle.vue";
|
2018-07-10 09:16:24 +00:00
|
|
|
import ListBans from "./Special/ListBans.vue";
|
2019-04-14 11:44:44 +00:00
|
|
|
import ListInvites from "./Special/ListInvites.vue";
|
2018-07-10 09:37:48 +00:00
|
|
|
import ListChannels from "./Special/ListChannels.vue";
|
2018-07-11 07:54:32 +00:00
|
|
|
import ListIgnored from "./Special/ListIgnored.vue";
|
2018-07-08 10:50:11 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Chat",
|
|
|
|
components: {
|
2018-07-12 08:41:40 +00:00
|
|
|
ParsedMessage,
|
2018-07-08 17:22:01 +00:00
|
|
|
MessageList,
|
2018-07-08 13:42:54 +00:00
|
|
|
ChatInput,
|
2018-07-08 17:22:01 +00:00
|
|
|
ChatUserList,
|
2019-04-13 20:44:04 +00:00
|
|
|
SidebarToggle,
|
2018-07-08 10:50:11 +00:00
|
|
|
},
|
|
|
|
props: {
|
2018-07-08 12:18:17 +00:00
|
|
|
network: Object,
|
2018-07-08 10:50:11 +00:00
|
|
|
channel: Object,
|
|
|
|
},
|
2018-07-10 09:16:24 +00:00
|
|
|
computed: {
|
|
|
|
specialComponent() {
|
2018-07-10 09:37:48 +00:00
|
|
|
switch (this.channel.special) {
|
2019-07-17 09:33:59 +00:00
|
|
|
case "list_bans":
|
|
|
|
return ListBans;
|
|
|
|
case "list_invites":
|
|
|
|
return ListInvites;
|
|
|
|
case "list_channels":
|
|
|
|
return ListChannels;
|
|
|
|
case "list_ignored":
|
|
|
|
return ListIgnored;
|
2018-07-10 09:16:24 +00:00
|
|
|
}
|
2018-12-17 10:29:49 +00:00
|
|
|
|
|
|
|
return undefined;
|
2018-07-10 09:16:24 +00:00
|
|
|
},
|
|
|
|
},
|
2019-10-17 16:56:44 +00:00
|
|
|
watch: {
|
2019-11-11 19:18:55 +00:00
|
|
|
channel() {
|
|
|
|
this.channelChanged();
|
2019-10-17 16:56:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.channelChanged();
|
|
|
|
},
|
2018-09-14 13:28:39 +00:00
|
|
|
methods: {
|
2019-11-11 19:18:55 +00:00
|
|
|
channelChanged() {
|
2019-10-17 16:56:44 +00:00
|
|
|
// Triggered when active channel is set or changed
|
|
|
|
this.channel.highlight = 0;
|
|
|
|
this.channel.unread = 0;
|
|
|
|
|
|
|
|
socket.emit("open", this.channel.id);
|
|
|
|
|
|
|
|
if (this.channel.usersOutdated) {
|
|
|
|
this.channel.usersOutdated = false;
|
|
|
|
|
|
|
|
socket.emit("names", {
|
|
|
|
target: this.channel.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2018-09-14 13:28:39 +00:00
|
|
|
hideUserVisibleError() {
|
2019-11-02 19:40:59 +00:00
|
|
|
this.$store.commit("currentUserVisibleError", null);
|
2018-09-14 17:22:54 +00:00
|
|
|
},
|
2019-08-03 10:09:55 +00:00
|
|
|
editTopic() {
|
|
|
|
if (this.channel.type === "channel") {
|
|
|
|
this.channel.editTopic = true;
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
2019-08-11 13:59:06 +00:00
|
|
|
document.querySelector(`#chan-${this.channel.id} .topic-input`).focus();
|
2019-08-03 10:09:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2019-08-11 13:59:06 +00:00
|
|
|
saveTopic() {
|
2019-08-03 10:09:55 +00:00
|
|
|
this.channel.editTopic = false;
|
2019-08-11 13:59:06 +00:00
|
|
|
const newTopic = document.querySelector(`#chan-${this.channel.id} .topic-input`).value;
|
2019-08-03 10:09:55 +00:00
|
|
|
|
|
|
|
if (this.channel.topic !== newTopic) {
|
|
|
|
const target = this.channel.id;
|
|
|
|
const text = `/raw TOPIC ${this.channel.name} :${newTopic}`;
|
|
|
|
socket.emit("input", {target, text});
|
|
|
|
}
|
|
|
|
},
|
2019-11-09 22:21:34 +00:00
|
|
|
openContextMenu(event) {
|
|
|
|
const items = generateChannelContextMenu(this.$root, this.channel, this.network);
|
|
|
|
this.$root.$refs.app.openContextMenu(event, items);
|
|
|
|
},
|
2018-09-14 13:28:39 +00:00
|
|
|
},
|
2018-07-12 11:14:15 +00:00
|
|
|
};
|
2018-07-08 10:50:11 +00:00
|
|
|
</script>
|