Introduce buffer type

This commit is contained in:
Simon Ser 2020-06-26 10:35:38 +02:00
parent 5f30662fc0
commit 6d3621e1be
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 21 additions and 5 deletions

View file

@ -7,7 +7,9 @@ import Connect from "/components/connect.js";
import Composer from "/components/composer.js";
import ScrollManager from "/components/scroll-manager.js";
import { html, Component, createRef } from "/lib/index.js";
import { SERVER_BUFFER, Status, Unread } from "/state.js";
import { BufferType, Status, Unread } from "/state.js";
const SERVER_BUFFER = "*";
function parseQueryString() {
var query = window.location.search.substring(1);
@ -107,9 +109,19 @@ export default class App extends Component {
return;
}
var type;
if (name == SERVER_BUFFER) {
type = BufferType.SERVER;
} else if (this.isChannel(name)) {
type = BufferType.CHANNEL;
} else {
type = BufferType.NICK;
}
var buffers = new Map(state.buffers);
buffers.set(name, {
name: name,
name,
type,
topic: null,
members: new Map(),
messages: [],

View file

@ -1,5 +1,5 @@
import { html, Component } from "/lib/index.js";
import { SERVER_BUFFER, Unread } from "/state.js";
import { BufferType, Unread } from "/state.js";
function BufferItem(props) {
function handleClick(event) {
@ -8,7 +8,7 @@ function BufferItem(props) {
}
var name = props.buffer.name;
if (name == SERVER_BUFFER) {
if (props.buffer.type == BufferType.SERVER) {
name = "server";
}

View file

@ -1,4 +1,8 @@
export const SERVER_BUFFER = "*";
export const BufferType = {
SERVER: "server",
CHANNEL: "channel",
NICK: "nick",
};
export const Status = {
DISCONNECTED: "disconnected",