From 90a2c91651a2639f93c0979abc72851e8d43cab5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 23 Oct 2022 20:18:33 +0200 Subject: [PATCH] Load initial members state via WHO when channel is selected Closes: https://todo.sr.ht/~emersion/gamja/13 --- components/app.js | 18 +++++++++++++++++- state.js | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/components/app.js b/components/app.js index d3c60ae..134896d 100644 --- a/components/app.js +++ b/components/app.js @@ -578,6 +578,10 @@ export default class App extends Component { this.whoUserBuffer(buf.name, buf.server); } + if (buf.type === BufferType.CHANNEL && !buf.hasInitialWho) { + this.whoChannelBuffer(buf.name, buf.server); + } + if (buf.type !== BufferType.SERVER) { document.title = buf.name + ' ยท ' + this.baseTitle; } else { @@ -1349,6 +1353,16 @@ export default class App extends Component { } } + whoChannelBuffer(target, serverID) { + let client = this.clients.get(serverID); + + client.who(target, { + fields: ["flags", "hostname", "nick", "realname", "username", "account"], + }).then(() => { + this.setBufferState({ name: target, server: serverID }, { hasInitialWho: true }); + }); + } + open(target, serverID, password) { if (!serverID) { serverID = State.getActiveServerID(this.state); @@ -1359,7 +1373,9 @@ export default class App extends Component { this.switchBuffer({ server: serverID }); } else if (client.isChannel(target)) { this.switchToChannel = target; - client.join(target, password).catch((err) => { + client.join(target, password).then(() => { + this.whoChannelBuffer(target, serverID); + }).catch((err) => { this.showError(err); }); } else { diff --git a/state.js b/state.js index de52790..4510252 100644 --- a/state.js +++ b/state.js @@ -343,6 +343,7 @@ export const State = { serverInfo: null, // if server joined: false, // if channel topic: null, // if channel + hasInitialWho: false, // if channel members: new irc.CaseMapMap(null, client.cm), // if channel messages: [], unread: Unread.NONE,