From dd8eca1cfeed6aecac9bb4dc2fd2c2079ab81784 Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Thu, 10 Jun 2021 12:03:50 +0200
Subject: [PATCH] Switch to server buffer on server name click

Closes: https://todo.sr.ht/~emersion/gamja/68
---
 components/app.js | 5 +++--
 lib/client.js     | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/components/app.js b/components/app.js
index 35c661d..91b0496 100644
--- a/components/app.js
+++ b/components/app.js
@@ -757,8 +757,9 @@ export default class App extends Component {
 		}
 
 		var client = this.clients.get(serverID);
-
-		if (client.isChannel(target)) {
+		if (client.isServer(target)) {
+			this.switchBuffer({ server: serverID });
+		} else if (client.isChannel(target)) {
 			this.switchToChannel = target;
 			client.send({ command: "JOIN", params: [target] });
 		} else {
diff --git a/lib/client.js b/lib/client.js
index 743f2db..41994c5 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -471,6 +471,10 @@ export default class Client extends EventTarget {
 		this.whoisDB = new irc.CaseMapMap(this.whoisDB, this.cm);
 	}
 
+	isServer(name) {
+		return name === "*" || this.cm(name) === this.cm(this.serverPrefix.name);
+	}
+
 	isMyNick(nick) {
 		return this.cm(nick) == this.cm(this.nick);
 	}