unregister caps_slot_ on event

This commit is contained in:
Eric Mertens 2025-01-27 17:04:31 -08:00
parent a9d6eb3811
commit 7cd92ececb

View File

@ -19,12 +19,15 @@ Registration::Registration(
auto Registration::on_connect() -> void auto Registration::on_connect() -> void
{ {
auto &connection = client_->get_connection();
client_->list_caps(); client_->list_caps();
caps_slot_ = client_->sig_cap_ls.connect([self = shared_from_this()](auto &caps) { caps_slot_ = client_->sig_cap_ls.connect([self = shared_from_this()](auto &caps) {
self->caps_slot_.disconnect();
self->on_cap_list(caps); self->on_cap_list(caps);
}); });
slot_ = client_->get_connection().sig_ircmsg.connect( slot_ = connection.sig_ircmsg.connect(
[self = shared_from_this()](const auto cmd, auto &msg) [self = shared_from_this()](const auto cmd, auto &msg)
{ {
self->on_ircmsg(cmd, msg); self->on_ircmsg(cmd, msg);
@ -33,10 +36,10 @@ auto Registration::on_connect() -> void
if (not settings_.password.empty()) if (not settings_.password.empty())
{ {
client_->get_connection().send_pass(settings_.password); connection.send_pass(settings_.password);
} }
client_->get_connection().send_user(settings_.username, settings_.realname); connection.send_user(settings_.username, settings_.realname);
client_->get_connection().send_nick(settings_.nickname); connection.send_nick(settings_.nickname);
} }
auto Registration::on_cap_list(const std::unordered_map<std::string, std::string> &caps) -> void auto Registration::on_cap_list(const std::unordered_map<std::string, std::string> &caps) -> void