shared: extract chan + user

This commit is contained in:
Reto Brunner 2024-02-24 11:29:07 +01:00
commit d0b71aba32
3 changed files with 55 additions and 4 deletions

43
shared/types/chan.ts Normal file
View file

@ -0,0 +1,43 @@
import {SharedMsg} from "./msg";
import {SharedUser} from "./user";
export enum ChanType {
CHANNEL = "channel",
LOBBY = "lobby",
QUERY = "query",
SPECIAL = "special",
}
export enum SpecialChanType {
BANLIST = "list_bans",
INVITELIST = "list_invites",
CHANNELLIST = "list_channels",
IGNORELIST = "list_ignored",
}
export enum ChanState {
PARTED = 0,
JOINED = 1,
}
export type SharedChan = {
// TODO: don't force existence, figure out how to make TS infer it.
id: number;
messages: SharedMsg[];
name: string;
key: string;
topic: string;
firstUnread: number;
unread: number;
highlight: number;
users: Map<string, SharedUser>;
muted: boolean;
type: ChanType;
state: ChanState;
userAway?: boolean;
special?: SpecialChanType;
data?: any;
closed?: boolean;
num_users?: number;
};

8
shared/types/user.ts Normal file
View file

@ -0,0 +1,8 @@
export type SharedUser = {
modes: string[];
// Users in the channel have only one mode assigned
mode: string;
away: string;
nick: string;
lastMessage: number;
};