Skip to content

Commit

Permalink
Merge branch 'master' into fix/mismatched-size
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Jan 12, 2025
2 parents 07b7bf7 + 7dbb27e commit deb3ff9
Show file tree
Hide file tree
Showing 33 changed files with 807 additions and 199 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ env:
C2_ENABLE_LTO: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/bugfix-release/') || startsWith(github.ref, 'refs/heads/release/') }}
CHATTERINO_REQUIRE_CLEAN_GIT: On
C2_BUILD_WITH_QT6: Off
# Last known good conan version
# 2.0.3 has a bug on Windows (conan-io/conan#13606)
CONAN_VERSION: 2.0.2
CONAN_VERSION: 2.11.0

jobs:
build-ubuntu-docker:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ env:
TWITCH_PUBSUB_SERVER_TAG: v1.0.7
HTTPBOX_TAG: v0.2.1
QT_QPA_PLATFORM: minimal
# Last known good conan version
# 2.0.3 has a bug on Windows (conan-io/conan#13606)
CONAN_VERSION: 2.0.2
CONAN_VERSION: 2.11.0

concurrency:
group: test-windows-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
working-directory: build-test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5.0.7
uses: codecov/codecov-action@v5.1.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
plugins: gcov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/winget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: windows-latest
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
steps:
- uses: vedantmgoyal2009/winget-releaser@v2
- uses: vedantmgoyal9/winget-releaser@main
with:
identifier: ChatterinoTeam.Chatterino
installers-regex: ^Chatterino.Installer.exe$
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

## Unversioned

- Minor: `/clear` messages are now stacked like timeouts. (#5806)
- Minor: Treat all browsers starting with `firefox` as a Firefox browser. (#5805)
- Minor: Remove incognito browser support for `opera/launcher` (this should no longer be a thing). (#5805)
- Minor: Remove incognito browser support for `iexplore`, because internet explorer is EOL. (#5810)
- Bugfix: Fixed a crash relating to Lua HTTP. (#5800)
- Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818)
- Bugfix: Fixed missing word wrap in update popup. (#5811)
- Bugfix: Fixed tabs not scaling to the default scale when changing the scale from a non-default value. (#5794)
- Dev: Updated Conan dependencies. (#5776)

## 2.5.2

Expand Down
20 changes: 16 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from conan import ConanFile
from conan.tools.files import copy
from conan.tools.cmake import CMakeToolchain
from os import path


class Chatterino(ConanFile):
name = "Chatterino"
requires = "boost/1.83.0"
requires = "boost/1.86.0"
settings = "os", "compiler", "build_type", "arch"
default_options = {
"with_benchmark": False,
Expand All @@ -18,18 +19,29 @@ class Chatterino(ConanFile):
# Qt is built with OpenSSL 3 from version 6.5.0 onwards
"with_openssl3": [True, False],
}
generators = "CMakeDeps", "CMakeToolchain"
generators = "CMakeDeps"

def requirements(self):
if self.options.get_safe("with_benchmark", False):
self.requires("benchmark/1.7.1")
self.requires("benchmark/1.9.0")

if self.options.get_safe("with_openssl3", False):
self.requires("openssl/3.2.0")
self.requires("openssl/3.3.2")
else:
self.requires("openssl/1.1.1t")

def generate(self):
tc = CMakeToolchain(self)
tc.blocks.remove("compilers")
tc.blocks.remove("cmake_flags_init")
tc.blocks.remove("cppstd")
tc.blocks.remove("libcxx")
tc.blocks.remove("generic_system")
tc.blocks.remove("user_toolchain")
tc.blocks.remove("output_dirs")
tc.blocks.remove("apple_system")
tc.generate()

def copy_bin(dep, selector, subdir):
src = path.realpath(dep.cpp_info.bindirs[0])
dst = path.realpath(path.join(self.build_folder, subdir))
Expand Down
13 changes: 9 additions & 4 deletions docs/make-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
- [ ] Update the changelog `## Unreleased` section to the new version `CHANGELOG.md`
Make sure to leave the `## Unreleased` line unchanged for easier merges

- [ ] Ensure all GitHub API credentials from the `chatterino-ci` user are still valid

## After the PR has been merged

- [ ] Tag the release
- [ ] Manually run the [create-installer](https://github.com/Chatterino/chatterino2/actions/workflows/create-installer.yml) workflow.
This is only necessary if the tag was created after the CI in the main branch finished.
- [ ] Start a manual [Launchpad import](https://code.launchpad.net/~pajlada/chatterino/+git/chatterino) - scroll down & click Import Now
- [ ] Make a PPA release to [this repo](https://git.launchpad.net/~pajlada/+git/chatterino-packaging/) with the `debchange` command.
`debchange -v 2.4.0` then add the changelog entries
`debchange --release` then change the distro to be `unstable`
- [ ] If the winget releaser action doesn't work as expected, you can run this manually using [Komac](https://github.com/russellbanks/Komac), replacing `v2.5.2` with the current release:
`komac update ChatterinoTeam.Chatterino --version 2.5.2 --urls https://github.com/Chatterino/chatterino2/releases/download/v2.5.2/Chatterino.Installer.exe`

## After the binaries have been uploaded to fourtf's bucket

- [ ] Re-run the Publish Homebrew Cask on Release action
- [ ] Update links in the Chatterino website to point to the new release
12 changes: 12 additions & 0 deletions src/common/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ void Channel::addOrReplaceTimeout(MessagePtr message, QTime now)
// WindowManager::instance().repaintVisibleChatWidgets(this);
}

void Channel::addOrReplaceClearChat(MessagePtr message, QTime now)
{
addOrReplaceChannelClear(
this->getMessageSnapshot(), std::move(message), now,
[this](auto /*idx*/, auto msg, auto replacement) {
this->replaceMessage(msg, replacement);
},
[this](auto msg) {
this->addMessage(msg, MessageContext::Original);
});
}

void Channel::disableAllMessages()
{
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
Expand Down
1 change: 1 addition & 0 deletions src/common/Channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Channel : public std::enable_shared_from_this<Channel>, public MessageSink
void fillInMissingMessages(const std::vector<MessagePtr> &messages);

void addOrReplaceTimeout(MessagePtr message, QTime now) final;
void addOrReplaceClearChat(MessagePtr message, QTime now) final;
void disableAllMessages() final;
void replaceMessage(const MessagePtr &message,
const MessagePtr &replacement);
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/plugins/api/HTTPRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ void HTTPRequest::createUserType(sol::table &c2)
);
}

void HTTPRequest::on_success(sol::protected_function func)
void HTTPRequest::on_success(sol::main_protected_function func)
{
this->cbSuccess = std::make_optional(func);
}

void HTTPRequest::on_error(sol::protected_function func)
void HTTPRequest::on_error(sol::main_protected_function func)
{
this->cbError = std::make_optional(func);
}
Expand All @@ -64,7 +64,7 @@ void HTTPRequest::set_timeout(int timeout)
this->timeout_ = timeout;
}

void HTTPRequest::finally(sol::protected_function func)
void HTTPRequest::finally(sol::main_protected_function func)
{
this->cbFinally = std::make_optional(func);
}
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/plugins/api/HTTPRequest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class HTTPRequest : public std::enable_shared_from_this<HTTPRequest>
int timeout_ = 10'000;
bool done = false;

std::optional<sol::protected_function> cbSuccess;
std::optional<sol::protected_function> cbError;
std::optional<sol::protected_function> cbFinally;
std::optional<sol::main_protected_function> cbSuccess;
std::optional<sol::main_protected_function> cbError;
std::optional<sol::main_protected_function> cbFinally;

public:
// These functions are wrapped so data can be accessed more easily. When a call from Lua comes in:
Expand All @@ -64,23 +64,23 @@ class HTTPRequest : public std::enable_shared_from_this<HTTPRequest>
* @lua@param callback c2.HTTPCallback Function to call when the HTTP request succeeds
* @exposed c2.HTTPRequest:on_success
*/
void on_success(sol::protected_function func);
void on_success(sol::main_protected_function func);

/**
* Sets the failure callback
*
* @lua@param callback c2.HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
* @exposed c2.HTTPRequest:on_error
*/
void on_error(sol::protected_function func);
void on_error(sol::main_protected_function func);

/**
* Sets the finally callback
*
* @lua@param callback fun(): nil Function to call when the HTTP request finishes
* @exposed c2.HTTPRequest:finally
*/
void finally(sol::protected_function func);
void finally(sol::main_protected_function func);

/**
* Sets the timeout
Expand Down
41 changes: 41 additions & 0 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <QDateTime>
#include <QDebug>
#include <QFileInfo>
#include <QStringBuilder>
#include <QTimeZone>

#include <algorithm>
Expand Down Expand Up @@ -1986,6 +1987,46 @@ MessagePtr MessageBuilder::makeLowTrustUpdateMessage(
return builder.release();
}

MessagePtrMut MessageBuilder::makeClearChatMessage(QTime now,
const QString &actor,
uint32_t count)
{
MessageBuilder builder;
builder.emplace<TimestampElement>(now);
builder->count = count;
builder->parseTime = now;
builder.message().flags.set(MessageFlag::System,
MessageFlag::DoNotTriggerNotification,
MessageFlag::ClearChat);

QString messageText;
if (actor.isEmpty())
{
builder.emplaceSystemTextAndUpdate(
"Chat has been cleared by a moderator.", messageText);
}
else
{
builder.message().flags.set(MessageFlag::PubSub);
builder.emplace<MentionElement>(actor, actor, MessageColor::System,
MessageColor::System);
messageText = actor + ' ';
builder.emplaceSystemTextAndUpdate("cleared the chat.", messageText);
builder->timeoutUser = actor;
}

if (count > 1)
{
builder.emplaceSystemTextAndUpdate(
'(' % QString::number(count) % u" times)", messageText);
}

builder->messageText = messageText;
builder->searchText = messageText;

return builder.release();
}

std::pair<MessagePtrMut, HighlightAlert> MessageBuilder::makeIrcMessage(
/* mutable */ Channel *channel, const Communi::IrcMessage *ircMessage,
const MessageParseArgs &args, /* mutable */ QString content,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/MessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ class MessageBuilder
const QVariantMap &tags,
const QTime &time);

/// "Chat has been cleared by a moderator." or "{actor} cleared the chat."
/// @param actor The user who cleared the chat (empty if unknown)
/// @param count How many times this message has been received already
static MessagePtrMut makeClearChatMessage(QTime now, const QString &actor,
uint32_t count = 1);

private:
struct TextState {
TwitchChannel *twitchChannel = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions src/messages/MessageFlag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ enum class MessageFlag : std::int64_t {
SharedMessage = (1LL << 37),
/// AutoMod message that showed up due to containing a blocked term in the channel
AutoModBlockedTerm = (1LL << 38),
/// The message is a full clear chat message (/clear)
ClearChat = (1LL << 39),
};
using MessageFlags = FlagsEnum<MessageFlag>;

Expand Down
5 changes: 5 additions & 0 deletions src/messages/MessageSink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class MessageSink
virtual void addOrReplaceTimeout(MessagePtr clearchatMessage,
QTime now) = 0;

/// Adds a clear chat message (for the entire chat) or merges it into an
/// existing one
virtual void addOrReplaceClearChat(MessagePtr clearchatMessage,
QTime now) = 0;

/// Flags all messages as `Disabled`
virtual void disableAllMessages() = 0;

Expand Down
20 changes: 8 additions & 12 deletions src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ std::optional<ClearChatMessage> parseClearChatMessage(
if (message->parameters().length() == 1)
{
return ClearChatMessage{
.message =
makeSystemMessage("Chat has been cleared by a moderator.",
calculateMessageTime(message).time()),
.message = MessageBuilder::makeClearChatMessage(
calculateMessageTime(message).time(), {}),
.disableAllMessages = true,
};
}
Expand Down Expand Up @@ -320,15 +319,14 @@ void IrcMessageHandler::parseMessageInto(Communi::IrcMessage *message,
return;
}
auto &clearChat = *cc;
auto time = calculateMessageTime(message).time();
if (clearChat.disableAllMessages)
{
sink.addMessage(std::move(clearChat.message),
MessageContext::Original);
sink.addOrReplaceClearChat(std::move(clearChat.message), time);
}
else
{
sink.addOrReplaceTimeout(std::move(clearChat.message),
calculateMessageTime(message).time());
sink.addOrReplaceTimeout(std::move(clearChat.message), time);
}
}
}
Expand Down Expand Up @@ -464,18 +462,16 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
return;
}

auto time = calculateMessageTime(message).time();
// chat has been cleared by a moderator
if (clearChat.disableAllMessages)
{
chan->disableAllMessages();
chan->addMessage(std::move(clearChat.message),
MessageContext::Original);

chan->addOrReplaceClearChat(std::move(clearChat.message), time);
return;
}

chan->addOrReplaceTimeout(std::move(clearChat.message),
calculateMessageTime(message).time());
chan->addOrReplaceTimeout(std::move(clearChat.message), time);

// refresh all
getApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
Expand Down
9 changes: 4 additions & 5 deletions src/providers/twitch/TwitchIrcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,10 @@ void TwitchIrcServer::initialize()
return;
}

QString text =
QString("%1 cleared the chat.").arg(action.source.login);

postToThread([chan, text] {
chan->addSystemMessage(text);
postToThread([chan, actor{action.source.login}] {
auto now = QTime::currentTime();
chan->addOrReplaceClearChat(
MessageBuilder::makeClearChatMessage(now, actor), now);
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/singletons/Updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ void Updates::installUpdates()
QMessageBox::Information, "Chatterino Update",
"A link will open in your browser. Download and install to update.");
box->setAttribute(Qt::WA_DeleteOnClose);
box->exec();
box->open();
QDesktopServices::openUrl(this->updateExe_);
#elif defined Q_OS_LINUX
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Automatic updates are currently not available on "
"linux. Please redownload the app to update.");
"Linux. Please redownload the app to update.");
box->setAttribute(Qt::WA_DeleteOnClose);
box->exec();
box->open();
QDesktopServices::openUrl(this->updateGuideLink_);
#elif defined Q_OS_WIN
if (Modes::instance().isPortable)
Expand Down
Loading

0 comments on commit deb3ff9

Please sign in to comment.