diff --git a/src/messages/lazyloadedimage.cpp b/src/messages/lazyloadedimage.cpp index 1d9734672..88f1e2ffb 100644 --- a/src/messages/lazyloadedimage.cpp +++ b/src/messages/lazyloadedimage.cpp @@ -12,6 +12,7 @@ #include #include #include + #include namespace chatterino { diff --git a/src/messages/lazyloadedimage.h b/src/messages/lazyloadedimage.h index 54b5bea56..8e64d8df1 100644 --- a/src/messages/lazyloadedimage.h +++ b/src/messages/lazyloadedimage.h @@ -1,5 +1,4 @@ -#ifndef LAZYLOADEDIMAGE_H -#define LAZYLOADEDIMAGE_H +#pragma once #include #include @@ -103,7 +102,6 @@ private: void gifUpdateTimout(); }; + } // namespace messages } // namespace chatterino - -#endif // LAZYLOADEDIMAGE_H diff --git a/src/messages/message.cpp b/src/messages/message.cpp index 493509a22..c80eb2cea 100644 --- a/src/messages/message.cpp +++ b/src/messages/message.cpp @@ -21,13 +21,15 @@ namespace messages { Message::Message(const QString &text) : _words() + , _text(text) { _words.push_back( Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString())); } -Message::Message(const std::vector &words) +Message::Message(const QString &text, const std::vector &words) : _words(words) + , _text(text) { } diff --git a/src/messages/message.h b/src/messages/message.h index 89c3c3dc7..2b1ee3c81 100644 --- a/src/messages/message.h +++ b/src/messages/message.h @@ -25,7 +25,7 @@ class Message { public: Message(const QString &text); - Message(const std::vector &words); + Message(const QString &text, const std::vector &words); bool getCanHighlightTab() const; const QString &getTimeoutUser() const; @@ -38,6 +38,8 @@ public: bool isDisabled() const; const QString &getId() const; + const QString _text; + private: static LazyLoadedImage *badgeStaff; static LazyLoadedImage *badgeAdmin; diff --git a/src/messages/messagebuilder.cpp b/src/messages/messagebuilder.cpp index e44282efc..64de84973 100644 --- a/src/messages/messagebuilder.cpp +++ b/src/messages/messagebuilder.cpp @@ -14,7 +14,7 @@ MessageBuilder::MessageBuilder() SharedMessage MessageBuilder::build() { - return SharedMessage(new Message(_words)); + return SharedMessage(new Message(this->originalMessage, _words)); } void MessageBuilder::appendWord(const Word &word) diff --git a/src/messages/messagebuilder.h b/src/messages/messagebuilder.h index f6c38b06a..b27fb7df3 100644 --- a/src/messages/messagebuilder.h +++ b/src/messages/messagebuilder.h @@ -1,7 +1,7 @@ -#ifndef MESSAGEBUILDER_H -#define MESSAGEBUILDER_H +#pragma once #include "messages/message.h" + #include namespace chatterino { @@ -20,11 +20,12 @@ public: QString matchLink(const QString &string); + QString originalMessage; + private: std::vector _words; std::chrono::time_point _parseTime; }; -} -} -#endif // MESSAGEBUILDER_H +} // namespace messages +} // namespace chatterino diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp index ace9d2334..9b004537c 100644 --- a/src/twitch/twitchmessagebuilder.cpp +++ b/src/twitch/twitchmessagebuilder.cpp @@ -204,7 +204,9 @@ SharedMessage TwitchMessageBuilder::parse(const Communi::IrcPrivateMessage *ircM // words QColor textColor = ircMessage->isAction() ? usernameColor : ColorScheme::getInstance().Text; - QStringList splits = ircMessage->content().split(' '); + const QString &originalMessage = ircMessage->content(); + b.originalMessage = originalMessage; + QStringList splits = originalMessage.split(' '); long int i = 0; diff --git a/src/util/urlfetch.h b/src/util/urlfetch.h index 34786c6ba..fb89f90ab 100644 --- a/src/util/urlfetch.h +++ b/src/util/urlfetch.h @@ -1,5 +1,4 @@ -#ifndef URLFETCH_H -#define URLFETCH_H +#pragma once #include #include @@ -25,6 +24,16 @@ static void urlFetch(const QString &url, std::function su QNetworkReply *reply = manager->get(request); QObject::connect(reply, &QNetworkReply::finished, [=] { + /* uncomment to follow redirects + QVariant replyStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); + if (replyStatus >= 300 && replyStatus <= 304) { + QString newUrl = + reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString(); + urlFetch(newUrl, successCallback); + return; + } + */ + if (reply->error() == QNetworkReply::NetworkError::NoError) { successCallback(*reply); } @@ -49,7 +58,6 @@ static void urlJsonFetch(const QString &url, std::function successCallback(rootNode); }); } -} -} -#endif // URLFETCH_H +} // namespace util +} // namespace chatterino diff --git a/src/widgets/chatwidgetview.cpp b/src/widgets/chatwidgetview.cpp index dcc7377a8..4af5a56cc 100644 --- a/src/widgets/chatwidgetview.cpp +++ b/src/widgets/chatwidgetview.cpp @@ -112,7 +112,7 @@ bool ChatWidgetView::layoutMessages() _scrollbar.setMaximum(messages.getSize()); - if (showingLatestMessages && showScrollbar) { + if (this->showingLatestMessages && showScrollbar) { // If we were showing the latest messages and the scrollbar now wants to be rendered, scroll // to bottom // TODO: Do we want to check if the user is currently moving the scrollbar? diff --git a/src/widgets/scrollbar.cpp b/src/widgets/scrollbar.cpp index 4b87495b3..2eb02ff54 100644 --- a/src/widgets/scrollbar.cpp +++ b/src/widgets/scrollbar.cpp @@ -96,7 +96,7 @@ void ScrollBar::scrollToBottom() bool ScrollBar::isAtBottom() const { - return this->getCurrentValue() == this->getMaximum() - this->getLargeChange(); + return ((this->getMaximum() - this->getLargeChange()) - this->getCurrentValue()) <= 1; } void ScrollBar::setMaximum(qreal value)