mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed #237 /mentions
This commit is contained in:
parent
d741bf6df3
commit
fa344deaf0
|
@ -11,10 +11,9 @@
|
|||
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
class Message;
|
||||
|
||||
typedef std::shared_ptr<Message> MessagePtr;
|
||||
typedef uint16_t MessageFlagsType;
|
||||
class Message;
|
||||
typedef std::shared_ptr<Message> MessagePtr;
|
||||
|
||||
class Message
|
||||
{
|
||||
|
@ -86,6 +85,5 @@ private:
|
|||
|
||||
std::vector<std::unique_ptr<MessageElement>> elements;
|
||||
};
|
||||
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -8,7 +8,6 @@ public:
|
|||
bool disablePingSoungs = false;
|
||||
bool isReceivedWhisper = false;
|
||||
bool isSentWhisper = false;
|
||||
bool includeChannelName = false;
|
||||
};
|
||||
|
||||
} // namespace messages
|
||||
|
|
|
@ -256,7 +256,12 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
|||
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
||||
|
||||
if (!builder.isIgnored()) {
|
||||
c->addMessage(builder.parse());
|
||||
messages::MessagePtr message = builder.build();
|
||||
if (message->hasFlags(messages::Message::Highlighted)) {
|
||||
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(message);
|
||||
}
|
||||
|
||||
c->addMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "twitchchannel.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "messages/message.hpp"
|
||||
#include "singletons/channelmanager.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
|
@ -239,7 +241,7 @@ void TwitchChannel::fetchRecentMessages()
|
|||
messages::MessageParseArgs args;
|
||||
twitch::TwitchMessageBuilder builder(channel, privMsg, args);
|
||||
if (!builder.isIgnored()) {
|
||||
messages.push_back(builder.parse());
|
||||
messages.push_back(builder.build());
|
||||
}
|
||||
}
|
||||
channel->addMessagesAtStart(messages);
|
||||
|
|
|
@ -44,7 +44,7 @@ bool TwitchMessageBuilder::isIgnored() const
|
|||
return false;
|
||||
}
|
||||
|
||||
MessagePtr TwitchMessageBuilder::parse()
|
||||
MessagePtr TwitchMessageBuilder::build()
|
||||
{
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||
|
@ -56,11 +56,14 @@ MessagePtr TwitchMessageBuilder::parse()
|
|||
// this->appendWord(Word(Resources::getInstance().badgeCollapsed, Word::Collapsed, QString(),
|
||||
// QString()));
|
||||
|
||||
// The timestamp is always appended to the builder
|
||||
// Whether or not will be rendered is decided/checked later
|
||||
// PARSING
|
||||
this->parseMessageID();
|
||||
|
||||
// Appends the correct timestamp if the message is a past message
|
||||
this->parseRoomID();
|
||||
|
||||
this->appendChannelName();
|
||||
|
||||
// timestamp
|
||||
bool isPastMsg = this->tags.contains("historical");
|
||||
if (isPastMsg) {
|
||||
// This may be architecture dependent(datatype)
|
||||
|
@ -71,20 +74,11 @@ MessagePtr TwitchMessageBuilder::parse()
|
|||
this->emplace<TimestampElement>();
|
||||
}
|
||||
|
||||
this->parseMessageID();
|
||||
|
||||
this->parseRoomID();
|
||||
|
||||
// TIMESTAMP
|
||||
this->emplace<TwitchModerationElement>();
|
||||
|
||||
this->parseTwitchBadges();
|
||||
this->appendTwitchBadges();
|
||||
|
||||
this->addChatterinoBadges();
|
||||
|
||||
if (this->args.includeChannelName) {
|
||||
this->parseChannelName();
|
||||
}
|
||||
this->appendChatterinoBadges();
|
||||
|
||||
this->appendUsername();
|
||||
|
||||
|
@ -232,7 +226,7 @@ void TwitchMessageBuilder::parseRoomID()
|
|||
}
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::parseChannelName()
|
||||
void TwitchMessageBuilder::appendChannelName()
|
||||
{
|
||||
QString channelName("#" + this->channel->name);
|
||||
Link link(Link::Url, this->channel->name + "\n" + this->messageID);
|
||||
|
@ -492,7 +486,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
|||
|
||||
// fourtf: this is ugly
|
||||
// maybe put the individual badges into a map instead of this mess
|
||||
void TwitchMessageBuilder::parseTwitchBadges()
|
||||
void TwitchMessageBuilder::appendTwitchBadges()
|
||||
{
|
||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
||||
const auto &channelResources = resourceManager.channels[this->roomID];
|
||||
|
@ -649,7 +643,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
}
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::addChatterinoBadges()
|
||||
void TwitchMessageBuilder::appendChatterinoBadges()
|
||||
{
|
||||
auto &badges = singletons::ResourceManager::getInstance().chatterinoBadges;
|
||||
auto it = badges.find(this->userName.toStdString());
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
QString userName;
|
||||
|
||||
bool isIgnored() const;
|
||||
messages::MessagePtr parse();
|
||||
messages::MessagePtr build();
|
||||
|
||||
private:
|
||||
QString roomID;
|
||||
|
@ -48,7 +48,7 @@ private:
|
|||
|
||||
void parseMessageID();
|
||||
void parseRoomID();
|
||||
void parseChannelName();
|
||||
void appendChannelName();
|
||||
void parseUsername();
|
||||
void appendUsername();
|
||||
void parseHighlights();
|
||||
|
@ -57,8 +57,8 @@ private:
|
|||
std::vector<std::pair<long, util::EmoteData>> &vec);
|
||||
bool tryAppendEmote(QString &emoteString);
|
||||
|
||||
void parseTwitchBadges();
|
||||
void addChatterinoBadges();
|
||||
void appendTwitchBadges();
|
||||
void appendChatterinoBadges();
|
||||
bool tryParseCheermote(const QString &string);
|
||||
};
|
||||
|
||||
|
|
|
@ -456,6 +456,9 @@ messages::MessageElement::Flags ChannelView::getFlags() const
|
|||
if (split->getModerationMode()) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
||||
}
|
||||
if (this->channel == singletons::ChannelManager::getInstance().mentionsChannel) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
|
|
|
@ -130,6 +130,9 @@ void Notebook::select(SplitContainer *page)
|
|||
if (this->selectedPage != nullptr) {
|
||||
this->selectedPage->setHidden(true);
|
||||
this->selectedPage->getTab()->setSelected(false);
|
||||
for (auto split : this->selectedPage->getSplits()) {
|
||||
split->updateLastReadMessage();
|
||||
}
|
||||
}
|
||||
|
||||
this->selectedPage = page;
|
||||
|
|
Loading…
Reference in a new issue