mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed #216 bundles connected and disconnected
This commit is contained in:
parent
873eeec545
commit
db41044daf
2 changed files with 17 additions and 5 deletions
|
@ -14,7 +14,7 @@ namespace messages {
|
||||||
class Message;
|
class Message;
|
||||||
|
|
||||||
typedef std::shared_ptr<Message> MessagePtr;
|
typedef std::shared_ptr<Message> MessagePtr;
|
||||||
typedef uint8_t MessageFlagsType;
|
typedef uint16_t MessageFlagsType;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ public:
|
||||||
Disabled = (1 << 5),
|
Disabled = (1 << 5),
|
||||||
DisableCompactEmotes = (1 << 6),
|
DisableCompactEmotes = (1 << 6),
|
||||||
Collapsed = (1 << 7),
|
Collapsed = (1 << 7),
|
||||||
|
DisconnectedMessage = (1 << 8),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Elements
|
// Elements
|
||||||
|
|
|
@ -382,9 +382,20 @@ void IrcManager::removeIgnoredUser(QString const &username)
|
||||||
void IrcManager::onConnected()
|
void IrcManager::onConnected()
|
||||||
{
|
{
|
||||||
MessagePtr msg = Message::createSystemMessage("connected to chat");
|
MessagePtr msg = Message::createSystemMessage("connected to chat");
|
||||||
|
MessagePtr remsg = Message::createSystemMessage("reconnected to chat");
|
||||||
|
|
||||||
this->channelManager.doOnAll([msg](SharedChannel channel) {
|
this->channelManager.doOnAll([msg, remsg](SharedChannel channel) {
|
||||||
assert(channel);
|
assert(channel);
|
||||||
|
|
||||||
|
LimitedQueueSnapshot<MessagePtr> snapshot = channel->getMessageSnapshot();
|
||||||
|
|
||||||
|
if (snapshot.getLength() > 0 &&
|
||||||
|
snapshot[snapshot.getLength() - 1]->hasFlags(Message::DisconnectedMessage)) //
|
||||||
|
{
|
||||||
|
channel->replaceMessage(snapshot[snapshot.getLength() - 1], remsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
channel->addMessage(msg);
|
channel->addMessage(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -392,6 +403,7 @@ void IrcManager::onConnected()
|
||||||
void IrcManager::onDisconnected()
|
void IrcManager::onDisconnected()
|
||||||
{
|
{
|
||||||
MessagePtr msg = Message::createSystemMessage("disconnected from chat");
|
MessagePtr msg = Message::createSystemMessage("disconnected from chat");
|
||||||
|
msg->addFlags(Message::DisconnectedMessage);
|
||||||
|
|
||||||
this->channelManager.doOnAll([msg](SharedChannel channel) {
|
this->channelManager.doOnAll([msg](SharedChannel channel) {
|
||||||
assert(channel);
|
assert(channel);
|
||||||
|
@ -404,12 +416,11 @@ Communi::IrcConnection *IrcManager::getReadConnection()
|
||||||
return this->readConnection.get();
|
return this->readConnection.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void IrcManager::addFakeMessage(const QString &data)
|
||||||
IrcManager::addFakeMessage(const QString &data)
|
|
||||||
{
|
{
|
||||||
auto fakeMessage = Communi::IrcMessage::fromData(data.toUtf8(), this->readConnection.get());
|
auto fakeMessage = Communi::IrcMessage::fromData(data.toUtf8(), this->readConnection.get());
|
||||||
|
|
||||||
this->privateMessageReceived(qobject_cast<Communi::IrcPrivateMessage*>(fakeMessage));
|
this->privateMessageReceived(qobject_cast<Communi::IrcPrivateMessage *>(fakeMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace singletons
|
} // namespace singletons
|
||||||
|
|
Loading…
Reference in a new issue