mirror of
https://github.com/thelounge/thelounge.git
synced 2026-03-14 14:35:50 +01:00
- error.ts: Store user's preferred nick (network.nick) in keepNick, not session nick - error.ts: Remove unnecessary client nick emit after fallback - welcome.ts: Don't overwrite preferred nick when registered with fallback - Allows existing quit handler to naturally reclaim preferred nick when it becomes available
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import {IrcEventHandler} from "../../client";
|
|
|
|
import Msg from "../../models/msg";
|
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
|
const client = this;
|
|
|
|
irc.on("registered", function (data) {
|
|
// Only update the user's preferred nick (network.nick) if we registered with it
|
|
// If we registered with a fallback nick (e.g., nick123), don't overwrite the preference
|
|
// This allows the existing quit handler to reclaim the preferred nick when available
|
|
if (data.nick === network.nick) {
|
|
// We got our preferred nick, clear keepNick if it was set
|
|
if (network.keepNick === data.nick) {
|
|
network.keepNick = null;
|
|
}
|
|
} else if (data.nick !== network.nick) {
|
|
// We registered with a fallback, don't call setNick which would overwrite the preference
|
|
// Just update the IRC session nick
|
|
irc.user.nick = data.nick;
|
|
}
|
|
|
|
const lobby = network.getLobby();
|
|
const msg = new Msg({
|
|
text: "You're now known as " + data.nick,
|
|
});
|
|
lobby.pushMessage(client, msg);
|
|
|
|
client.save();
|
|
client.emit("nick", {
|
|
network: network.uuid,
|
|
nick: data.nick,
|
|
});
|
|
});
|
|
};
|