Skip to content

Commit

Permalink
Merge branch 'master' into fix/reply-dotdotdot
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Feb 18, 2024
2 parents 86774c2 + 5c51ec8 commit 5e69543
Show file tree
Hide file tree
Showing 41 changed files with 1,075 additions and 341 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
- Minor: Added support for the `{input.text}` placeholder in the **Split** -> **Run a command** hotkey. (#5130)
- Minor: Add a new Channel API for experimental plugins feature. (#5141)
- Minor: Added the ability to change the top-most status of a window regardless of the _Always on top_ setting (right click the notebook). (#5135)
- Minor: Live streams that are marked as reruns now mark a tab as yellow instead of red. (#5176)
- Minor: Updated to Emoji v15.1. Google emojis are now used as the fallback instead of Twitter emojis. (#5182)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)
Expand All @@ -46,12 +48,14 @@
- Bugfix: Fixed too much text being copied when copying chat messages. (#4812, #4830, #4839)
- Bugfix: Fixed an issue where the setting `Only search for emote autocompletion at the start of emote names` wouldn't disable if it was enabled when the client started. (#4855)
- Bugfix: Fixed empty page being added when showing out of bounds dialog. (#4849)
- Bugfix: Fixed an issue preventing searching a redemption by it's title when the redemption contained text input. (#5117)
- Bugfix: Fixed issue on Windows preventing the title bar from being dragged in the top left corner. (#4873)
- Bugfix: Fixed an issue where reply context didn't render correctly if an emoji was touching text. (#4875, #4977, #5174)
- Bugfix: Fixed the input completion popup from disappearing when clicking on it on Windows and macOS. (#4876)
- Bugfix: Fixed double-click text selection moving its position with each new message. (#4898)
- Bugfix: Fixed an issue where notifications on Windows would contain no or an old avatar. (#4899)
- Bugfix: Fixed headers of tables in the settings switching to bold text when selected. (#4913)
- Bugfix: Fixed an issue in the `/live` split that caused some channels to not get grayed-out when they went offline. (#5172)
- Bugfix: Fixed tooltips appearing too large and/or away from the cursor. (#4920)
- Bugfix: Fixed a crash when clicking `More messages below` button in a usercard and closing it quickly. (#4933)
- Bugfix: Fixed thread popup window missing messages for nested threads. (#4923)
Expand All @@ -65,7 +69,7 @@
- Bugfix: Fixed rare crash with Image Uploader when closing a split right after starting an upload. (#4971)
- Bugfix: Fixed an issue on macOS where the image uploader would keep prompting the user even after they clicked "Yes, don't ask again". (#5011)
- Bugfix: Hide the Usercard button in the User Info Popup when in special channels. (#4972)
- Bugfix: Fixed support for Windows 11 Snap layouts. (#4994)
- Bugfix: Fixed support for Windows 11 Snap layouts. (#4994, #5175)
- Bugfix: Fixed some windows appearing between screens. (#4797)
- Bugfix: Fixed a crash that could occur when using certain features in a Usercard after closing the split from which it was created. (#5034, #5051)
- Bugfix: Fixed a crash that could occur when using certain features in a Reply popup after closing the split from which it was created. (#5036, #5051)
Expand All @@ -75,11 +79,13 @@
- Bugfix: Fixed avatar in usercard and moderation button triggering when releasing the mouse outside their area. (#5052)
- Bugfix: Fixed moderator-only topics being subscribed to for non-moderators. (#5056)
- Bugfix: Fixed a bug where buttons would remain in a hovered state after leaving them. (#5077)
- Bugfix: Fixed an issue where you had to click the `reply` button twice if you already had that users @ in your input box. (#5173)
- Bugfix: Fixed popup windows not persisting between restarts. (#5081)
- Bugfix: Fixed splits not retaining their focus after minimizing. (#5080)
- Bugfix: Fixed _Copy message_ copying the channel name in global search. (#5106)
- Bugfix: Reply contexts now use the color of the replied-to message. (#5145)
- Bugfix: Fixed top-level window getting stuck after opening settings. (#5161, #5166)
- Bugfix: Fixed link info not updating without moving the cursor. (#5178)
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
- Dev: Change clang-format from v14 to v16. (#4929)
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
Expand All @@ -103,6 +109,7 @@
- Dev: Replace `boost::optional` with `std::optional`. (#4877)
- Dev: Improve performance of selecting text. (#4889, #4911)
- Dev: Removed direct dependency on Qt 5 compatibility module. (#4906)
- Dev: Added unit test capabilities to SplitInput. (#5179)
- Dev: Refactor `Emoji`'s EmojiMap into a vector. (#4980)
- Dev: Refactor `DebugCount` and add copy button to debug popup. (#4921)
- Dev: Refactor `common/Credentials`. (#4979)
Expand Down
7 changes: 7 additions & 0 deletions mocks/include/mocks/EmptyApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ class EmptyApplication : public IApplication
return nullptr;
}

ILinkResolver *getLinkResolver() override
{
assert(false && "EmptyApplication::getLinkResolver was called without "
"being initialized");
return nullptr;
}

private:
Paths paths_;
Args args_;
Expand Down
6 changes: 6 additions & 0 deletions mocks/include/mocks/TwitchIrcServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ class MockTwitchIrcServer : public ITwitchIrcServer
return this->watchingChannel;
}

QString getLastUserThatWhisperedMe() const override
{
return this->lastUserThatWhisperedMe;
}

ChannelPtr watchingChannelInner;
IndirectChannel watchingChannel;
QString lastUserThatWhisperedMe{"forsen"};
};

} // namespace chatterino::mock
2 changes: 1 addition & 1 deletion resources/emoji.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "controllers/sound/ISoundController.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/links/LinkResolver.hpp"
#include "providers/seventv/SeventvAPI.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
#include "providers/twitch/TwitchBadges.hpp"
Expand Down Expand Up @@ -142,6 +143,7 @@ Application::Application(Settings &_settings, const Paths &paths,
, ffzEmotes(new FfzEmotes)
, seventvEmotes(new SeventvEmotes)
, logging(new Logging(_settings))
, linkResolver(new LinkResolver)
#ifdef CHATTERINO_HAVE_PLUGINS
, plugins(&this->emplace(new PluginController(paths)))
#endif
Expand Down Expand Up @@ -494,6 +496,13 @@ Logging *Application::getChatLogger()
return this->logging.get();
}

ILinkResolver *Application::getLinkResolver()
{
assertInGuiThread();

return this->linkResolver.get();
}

BttvEmotes *Application::getBttvEmotes()
{
assertInGuiThread();
Expand Down
5 changes: 5 additions & 0 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CrashHandler;
class BttvEmotes;
class FfzEmotes;
class SeventvEmotes;
class ILinkResolver;

class IApplication
{
Expand Down Expand Up @@ -95,6 +96,7 @@ class IApplication
virtual BttvEmotes *getBttvEmotes() = 0;
virtual FfzEmotes *getFfzEmotes() = 0;
virtual SeventvEmotes *getSeventvEmotes() = 0;
virtual ILinkResolver *getLinkResolver() = 0;
};

class Application : public IApplication
Expand Down Expand Up @@ -162,6 +164,7 @@ class Application : public IApplication
std::unique_ptr<FfzEmotes> ffzEmotes;
std::unique_ptr<SeventvEmotes> seventvEmotes;
const std::unique_ptr<Logging> logging;
std::unique_ptr<ILinkResolver> linkResolver;
#ifdef CHATTERINO_HAVE_PLUGINS
PluginController *const plugins{};
#endif
Expand Down Expand Up @@ -212,6 +215,8 @@ class Application : public IApplication
FfzEmotes *getFfzEmotes() override;
SeventvEmotes *getSeventvEmotes() override;

ILinkResolver *getLinkResolver() override;

pajlada::Signals::NoArgSignal streamerModeChanged;

private:
Expand Down
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,6 @@ set(SOURCE_FILES

providers/IvrApi.cpp
providers/IvrApi.hpp
providers/LinkResolver.cpp
providers/LinkResolver.hpp
providers/NetworkConfigurationProvider.cpp
providers/NetworkConfigurationProvider.hpp

Expand Down Expand Up @@ -345,6 +343,11 @@ set(SOURCE_FILES
providers/irc/IrcServer.cpp
providers/irc/IrcServer.hpp

providers/links/LinkInfo.cpp
providers/links/LinkInfo.hpp
providers/links/LinkResolver.cpp
providers/links/LinkResolver.hpp

providers/liveupdates/BasicPubSubClient.hpp
providers/liveupdates/BasicPubSubManager.hpp
providers/liveupdates/BasicPubSubWebsocket.hpp
Expand Down
5 changes: 5 additions & 0 deletions src/common/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ bool Channel::isLive() const
return false;
}

bool Channel::isRerun() const
{
return false;
}

bool Channel::shouldIgnoreHighlights() const
{
return this->type_ == Type::TwitchAutomod ||
Expand Down
1 change: 1 addition & 0 deletions src/common/Channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Channel : public std::enable_shared_from_this<Channel>
virtual bool hasModRights() const;
virtual bool hasHighRateLimit() const;
virtual bool isLive() const;
virtual bool isRerun() const;
virtual bool shouldIgnoreHighlights() const;
virtual bool canReconnect() const;
virtual void reconnect();
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/notifications/NotificationController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ void NotificationController::removeFakeChannel(const QString channelName)
{
const auto &s = snapshot[i];

if (s->messageText == liveMessageSearchText)
if (QString::compare(s->messageText, liveMessageSearchText,
Qt::CaseInsensitive) == 0)
{
s->flags.set(MessageFlag::Disabled);
break;
Expand Down
57 changes: 11 additions & 46 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "messages/Message.hpp"
#include "messages/MessageColor.hpp"
#include "messages/MessageElement.hpp"
#include "providers/LinkResolver.hpp"
#include "providers/links/LinkResolver.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "singletons/Emotes.hpp"
Expand Down Expand Up @@ -528,29 +528,27 @@ MessageBuilder::MessageBuilder(ImageUploaderResultTag /*unused*/,
this->emplace<TimestampElement>();

using MEF = MessageElementFlag;
auto addText = [this](QString text, MessageElementFlags mefs = MEF::Text,
auto addText = [this](QString text,
MessageColor color =
MessageColor::System) -> TextElement * {
this->message().searchText += text;
this->message().messageText += text;
return this->emplace<TextElement>(text, mefs, color);
return this->emplace<TextElement>(text, MEF::Text, color);
};

addText("Your image has been uploaded to");

// ASSUMPTION: the user gave this uploader configuration to the program
// therefore they trust that the host is not wrong/malicious. This doesn't obey getSettings()->lowercaseDomains.
// This also ensures that the LinkResolver doesn't get these links.
addText(imageLink, {MEF::OriginalLink, MEF::LowercaseLink},
MessageColor::Link)
addText(imageLink, MessageColor::Link)
->setLink({Link::Url, imageLink})
->setTrailingSpace(false);

if (!deletionLink.isEmpty())
{
addText("(Deletion link:");
addText(deletionLink, {MEF::OriginalLink, MEF::LowercaseLink},
MessageColor::Link)
addText(deletionLink, MessageColor::Link)
->setLink({Link::Url, deletionLink})
->setTrailingSpace(false);
addText(")")->setTrailingSpace(false);
Expand Down Expand Up @@ -634,46 +632,13 @@ void MessageBuilder::addLink(const ParsedLink &parsedLink)
lowercaseLinkString += parsedLink.host.toString().toLower();
lowercaseLinkString += parsedLink.rest;

auto linkElement = Link(Link::Url, matchedLink);

auto textColor = MessageColor(MessageColor::Link);
auto *linkMELowercase =
this->emplace<TextElement>(lowercaseLinkString,
MessageElementFlag::LowercaseLink, textColor)
->setLink(linkElement);
auto *linkMEOriginal =
this->emplace<TextElement>(origLink, MessageElementFlag::OriginalLink,
textColor)
->setLink(linkElement);

LinkResolver::getLinkInfo(
matchedLink, nullptr,
[weakMessage = this->weakOf(), linkMELowercase, linkMEOriginal,
matchedLink](QString tooltipText, Link originalLink,
ImagePtr thumbnail) {
auto shared = weakMessage.lock();
if (!shared)
{
return;
}
if (!tooltipText.isEmpty())
{
linkMELowercase->setTooltip(tooltipText);
linkMEOriginal->setTooltip(tooltipText);
}
if (originalLink.value != matchedLink &&
!originalLink.value.isEmpty())
{
linkMELowercase->setLink(originalLink)->updateLink();
linkMEOriginal->setLink(originalLink)->updateLink();
}
linkMELowercase->setThumbnail(thumbnail);
linkMELowercase->setThumbnailType(
MessageElement::ThumbnailType::Link_Thumbnail);
linkMEOriginal->setThumbnail(thumbnail);
linkMEOriginal->setThumbnailType(
MessageElement::ThumbnailType::Link_Thumbnail);
});
auto *el = this->emplace<LinkElement>(
LinkElement::Parsed{.lowercase = lowercaseLinkString,
.original = matchedLink},
MessageElementFlag::Text, textColor);
el->setLink({Link::Url, matchedLink});
getIApp()->getLinkResolver()->resolve(el->linkInfo());
}

void MessageBuilder::addIrcMessageText(const QString &text)
Expand Down
Loading

0 comments on commit 5e69543

Please sign in to comment.