Port ignore list to Vue
This commit is contained in:
parent
739d44b561
commit
771739cf94
@ -91,6 +91,7 @@ import ChatInput from "./ChatInput.vue";
|
||||
import ChatUserList from "./ChatUserList.vue";
|
||||
import ListBans from "./Special/ListBans.vue";
|
||||
import ListChannels from "./Special/ListChannels.vue";
|
||||
import ListIgnored from "./Special/ListIgnored.vue";
|
||||
|
||||
export default {
|
||||
name: "Chat",
|
||||
@ -109,6 +110,7 @@ export default {
|
||||
switch (this.channel.special) {
|
||||
case "list_bans": return ListBans;
|
||||
case "list_channels": return ListChannels;
|
||||
case "list_ignored": return ListIgnored;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
27
client/components/Special/ListIgnored.vue
Normal file
27
client/components/Special/ListIgnored.vue
Normal file
@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<table class="ignore-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="hostmask">Hostmask</th>
|
||||
<th class="when">Ignored At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="user in channel.data"
|
||||
:key="user.hostmask">
|
||||
<td class="hostmask">{{ user.hostmask }}</td>
|
||||
<td class="when">{{ user.when | localetime }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ListIgnored",
|
||||
props: {
|
||||
channel: Object,
|
||||
},
|
||||
};
|
||||
</script>
|
@ -64,12 +64,7 @@ function createFragment(fragment) {
|
||||
|
||||
// Transform an IRC message potentially filled with styling control codes, URLs,
|
||||
// nicknames, and channels into a string of HTML elements to display on the client.
|
||||
module.exports = function parse(text, users) {
|
||||
// if it's not the users we're expecting, but rather is passed from Handlebars (occurs when users passed to template is null or undefined)
|
||||
if (users && users.hash) {
|
||||
users = [];
|
||||
}
|
||||
|
||||
module.exports = function parse(text, users = []) {
|
||||
// Extract the styling information and get the plain text version from it
|
||||
const styleFragments = parseStyle(text);
|
||||
const cleanText = styleFragments.map((fragment) => fragment.text).join("");
|
||||
|
@ -1,18 +0,0 @@
|
||||
<table class="channel-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="channel">Channel</th>
|
||||
<th class="users">Users</th>
|
||||
<th class="topic">Topic</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each channels}}
|
||||
<tr>
|
||||
<td class="channel">{{{parse channel}}}</td>
|
||||
<td class="users">{{num_users}}</td>
|
||||
<td class="topic">{{{parse topic}}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
@ -1,16 +0,0 @@
|
||||
<table class="ignore-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="hostmask">Hostmask</th>
|
||||
<th class="when">Ignored At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each ignored}}
|
||||
<tr>
|
||||
<td class="hostmask">{{hostmask}}</td>
|
||||
<td class="when">{{{localetime when}}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
@ -92,27 +92,32 @@ exports.input = function(network, chan, cmd, args) {
|
||||
}));
|
||||
} else {
|
||||
const chanName = "Ignored users";
|
||||
const ignored = network.ignoreList.map((data) => ({
|
||||
hostmask: `${data.nick}!${data.ident}@${data.hostname}`,
|
||||
when: data.when,
|
||||
}));
|
||||
let newChan = network.getChannel(chanName);
|
||||
|
||||
if (typeof newChan === "undefined") {
|
||||
newChan = client.createChannel({
|
||||
type: Chan.Type.SPECIAL,
|
||||
special: Chan.SpecialType.IGNORELIST,
|
||||
name: chanName,
|
||||
data: ignored,
|
||||
});
|
||||
client.emit("join", {
|
||||
network: network.uuid,
|
||||
chan: newChan.getFilteredClone(true),
|
||||
index: network.addChannel(newChan),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
newChan.data = ignored;
|
||||
|
||||
newChan.pushMessage(client, new Msg({
|
||||
type: Msg.Type.IGNORELIST,
|
||||
ignored: network.ignoreList.map((data) => ({
|
||||
hostmask: `${data.nick}!${data.ident}@${data.hostname}`,
|
||||
when: data.when,
|
||||
})),
|
||||
}), true);
|
||||
client.emit("msg:special", {
|
||||
chan: newChan.id,
|
||||
data: ignored,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user