From 2d651ef901b2c19679651d201d4da4ce157c5ebb Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 19 Apr 2023 12:56:12 +0200 Subject: [PATCH] components/app: prevent multiple WHO channel commands in parallel References: https://todo.sr.ht/~emersion/gamja/152 --- components/app.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/app.js b/components/app.js index 2384c33..5c8cd23 100644 --- a/components/app.js +++ b/components/app.js @@ -1373,10 +1373,18 @@ export default class App extends Component { async whoChannelBuffer(target, serverID) { let client = this.clients.get(serverID); - await client.who(target, { - fields: ["flags", "hostname", "nick", "realname", "username", "account"], - }); + // Prevent multiple WHO commands for the same channel in parallel this.setBufferState({ name: target, server: serverID }, { hasInitialWho: true }); + + let hasInitialWho = false; + try { + await client.who(target, { + fields: ["flags", "hostname", "nick", "realname", "username", "account"], + }); + hasInitialWho = true; + } finally { + this.setBufferState({ name: target, server: serverID }, { hasInitialWho }); + } } open(target, serverID, password) {