Some whitespace is good mkey

This commit is contained in:
Reto Brunner 2024-03-03 15:38:01 +01:00
parent 636b5c5b04
commit 9aee3e3e98

View file

@ -122,6 +122,7 @@ class Chan {
} }
} }
} }
dereferencePreviews(messages) { dereferencePreviews(messages) {
if (!Config.values.prefetch || !Config.values.prefetchStorage) { if (!Config.values.prefetch || !Config.values.prefetchStorage) {
return; return;
@ -138,6 +139,7 @@ class Chan {
} }
}); });
} }
getSortedUsers(irc?: Network["irc"]) { getSortedUsers(irc?: Network["irc"]) {
const users = Array.from(this.users.values()); const users = Array.from(this.users.values());
@ -160,21 +162,27 @@ class Chan {
return userModeSortPriority[a.mode] - userModeSortPriority[b.mode]; return userModeSortPriority[a.mode] - userModeSortPriority[b.mode];
}); });
} }
findMessage(msgId: number) { findMessage(msgId: number) {
return this.messages.find((message) => message.id === msgId); return this.messages.find((message) => message.id === msgId);
} }
findUser(nick: string) { findUser(nick: string) {
return this.users.get(nick.toLowerCase()); return this.users.get(nick.toLowerCase());
} }
getUser(nick: string) { getUser(nick: string) {
return this.findUser(nick) || new User({nick}, new Prefix([])); return this.findUser(nick) || new User({nick}, new Prefix([]));
} }
setUser(user: User) { setUser(user: User) {
this.users.set(user.nick.toLowerCase(), user); this.users.set(user.nick.toLowerCase(), user);
} }
removeUser(user: User) { removeUser(user: User) {
this.users.delete(user.nick.toLowerCase()); this.users.delete(user.nick.toLowerCase());
} }
/** /**
* Get a clean clone of this channel that will be sent to the client. * Get a clean clone of this channel that will be sent to the client.
* This function performs manual cloning of channel object for * This function performs manual cloning of channel object for
@ -219,6 +227,7 @@ class Chan {
return newChannel; return newChannel;
}, {}) as SharedNetworkChan; }, {}) as SharedNetworkChan;
} }
writeUserLog(client: Client, msg: Msg) { writeUserLog(client: Client, msg: Msg) {
this.messages.push(msg); this.messages.push(msg);
@ -251,6 +260,7 @@ class Chan {
messageStorage.index(target.network, targetChannel, msg).catch((e) => log.error(e)); messageStorage.index(target.network, targetChannel, msg).catch((e) => log.error(e));
} }
} }
loadMessages(client: Client, network: Network) { loadMessages(client: Client, network: Network) {
if (!this.isLoggable()) { if (!this.isLoggable()) {
return; return;
@ -307,9 +317,11 @@ class Chan {
log.error(`Failed to load messages for ${client.name}: ${err.toString()}`) log.error(`Failed to load messages for ${client.name}: ${err.toString()}`)
); );
} }
isLoggable() { isLoggable() {
return this.type === ChanType.CHANNEL || this.type === ChanType.QUERY; return this.type === ChanType.CHANNEL || this.type === ChanType.QUERY;
} }
setMuteStatus(muted: boolean) { setMuteStatus(muted: boolean) {
this.muted = !!muted; this.muted = !!muted;
} }