diff --git a/components/app.js b/components/app.js index c5308f7..fb5ee84 100644 --- a/components/app.js +++ b/components/app.js @@ -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: [], diff --git a/components/buffer-list.js b/components/buffer-list.js index 45f665e..1f61099 100644 --- a/components/buffer-list.js +++ b/components/buffer-list.js @@ -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"; } diff --git a/state.js b/state.js index 4b32105..ee0f7b1 100644 --- a/state.js +++ b/state.js @@ -1,4 +1,8 @@ -export const SERVER_BUFFER = "*"; +export const BufferType = { + SERVER: "server", + CHANNEL: "channel", + NICK: "nick", +}; export const Status = { DISCONNECTED: "disconnected",