mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-15 03:35:10 -05:00
Introduce buffer type
This commit is contained in:
parent
5f30662fc0
commit
6d3621e1be
3 changed files with 21 additions and 5 deletions
|
@ -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: [],
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
6
state.js
6
state.js
|
@ -1,4 +1,8 @@
|
|||
export const SERVER_BUFFER = "*";
|
||||
export const BufferType = {
|
||||
SERVER: "server",
|
||||
CHANNEL: "channel",
|
||||
NICK: "nick",
|
||||
};
|
||||
|
||||
export const Status = {
|
||||
DISCONNECTED: "disconnected",
|
||||
|
|
Loading…
Reference in a new issue