models/chan: don't force existence of constructor properties
This commit is contained in:
parent
f785acb07d
commit
e31c95e32d
@ -34,19 +34,18 @@ export type FilteredChannel = Chan & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Chan {
|
class Chan {
|
||||||
// TODO: don't force existence, figure out how to make TS infer it.
|
id: number;
|
||||||
id!: number;
|
messages: Msg[];
|
||||||
messages!: Msg[];
|
name: string;
|
||||||
name!: string;
|
key: string;
|
||||||
key!: string;
|
topic: string;
|
||||||
topic!: string;
|
firstUnread: number;
|
||||||
firstUnread!: number;
|
unread: number;
|
||||||
unread!: number;
|
highlight: number;
|
||||||
highlight!: number;
|
users: Map<string, User>;
|
||||||
users!: Map<string, User>;
|
muted: boolean;
|
||||||
muted!: boolean;
|
type: ChanType;
|
||||||
type!: ChanType;
|
state: ChanState;
|
||||||
state!: ChanState;
|
|
||||||
|
|
||||||
userAway?: boolean;
|
userAway?: boolean;
|
||||||
special?: SpecialChanType;
|
special?: SpecialChanType;
|
||||||
@ -56,20 +55,22 @@ class Chan {
|
|||||||
static optionalProperties = ["userAway", "special", "data", "closed", "num_users"];
|
static optionalProperties = ["userAway", "special", "data", "closed", "num_users"];
|
||||||
|
|
||||||
constructor(attr?: Partial<Chan>) {
|
constructor(attr?: Partial<Chan>) {
|
||||||
_.defaults(this, attr, {
|
this.id = 0;
|
||||||
id: 0,
|
this.messages = [];
|
||||||
messages: [],
|
this.name = "";
|
||||||
name: "",
|
this.key = "";
|
||||||
key: "",
|
this.topic = "";
|
||||||
topic: "",
|
this.type = ChanType.CHANNEL;
|
||||||
type: ChanType.CHANNEL,
|
this.state = ChanState.PARTED;
|
||||||
state: ChanState.PARTED,
|
this.firstUnread = 0;
|
||||||
firstUnread: 0,
|
this.unread = 0;
|
||||||
unread: 0,
|
this.highlight = 0;
|
||||||
highlight: 0,
|
this.users = new Map();
|
||||||
users: new Map(),
|
this.muted = false;
|
||||||
muted: false,
|
|
||||||
});
|
if (attr) {
|
||||||
|
Object.assign(this, attr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
Loading…
Reference in New Issue
Block a user