From b4eb56f36211463edb441d1de9119dd5d6fde0a4 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 2 May 2020 06:18:35 -0400 Subject: [PATCH] Remove "Online Logs" functionality (#1649) The /logs command will direct users to the /user command instead Changelog has been updated to reflect this change --- CHANGELOG.md | 1 + chatterino.pro | 2 - .../commands/CommandController.cpp | 43 +----- src/widgets/dialogs/LogsPopup.cpp | 136 ------------------ src/widgets/dialogs/LogsPopup.hpp | 31 ---- src/widgets/dialogs/UserInfoPopup.cpp | 12 -- src/widgets/dialogs/UserInfoPopup.hpp | 1 - 7 files changed, 4 insertions(+), 222 deletions(-) delete mode 100644 src/widgets/dialogs/LogsPopup.cpp delete mode 100644 src/widgets/dialogs/LogsPopup.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 477bf3f5d..4ffded0e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned - Minor: Emotes in the emote popup are now sorted in the same order as the tab completion (#1549) +- Minor: Removed "Online Logs" functionality as services are shut down (#1640) - Bugfix: Fix preview on hover not working when Animated emotes options was disabled (#1546) - Bugfix: FFZ custom mod badges no longer scale with the emote scale options (#1602) - Settings open faster diff --git a/chatterino.pro b/chatterino.pro index 6ec03fee5..849b48e5b 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -229,7 +229,6 @@ SOURCES += \ src/widgets/dialogs/IrcConnectionEditor.cpp \ src/widgets/dialogs/LastRunCrashDialog.cpp \ src/widgets/dialogs/LoginDialog.cpp \ - src/widgets/dialogs/LogsPopup.cpp \ src/widgets/dialogs/NotificationPopup.cpp \ src/widgets/dialogs/QualityPopup.cpp \ src/widgets/dialogs/SelectChannelDialog.cpp \ @@ -451,7 +450,6 @@ HEADERS += \ src/widgets/dialogs/IrcConnectionEditor.hpp \ src/widgets/dialogs/LastRunCrashDialog.hpp \ src/widgets/dialogs/LoginDialog.hpp \ - src/widgets/dialogs/LogsPopup.hpp \ src/widgets/dialogs/NotificationPopup.hpp \ src/widgets/dialogs/QualityPopup.hpp \ src/widgets/dialogs/SelectChannelDialog.hpp \ diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index fa8a08e95..f44be76c1 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -16,7 +16,6 @@ #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "util/CombinePath.hpp" -#include "widgets/dialogs/LogsPopup.hpp" #include "widgets/dialogs/UserInfoPopup.hpp" #include @@ -416,45 +415,9 @@ QString CommandController::execCommand(const QString &textNoEmoji, } else if (commandName == "/logs") { - if (words.size() < 2) - { - channel->addMessage( - makeSystemMessage("Usage: /logs [user] (channel)")); - return ""; - } - auto app = getApp(); - - auto logs = new LogsPopup(); - QString target = words.at(1); - - if (target.at(0) == '@') - { - target = target.mid(1); - } - - logs->setTargetUserName(target); - - std::shared_ptr logsChannel = channel; - - if (words.size() == 3) - { - QString channelName = words.at(2); - if (words.at(2).at(0) == '#') - { - channelName = channelName.mid(1); - } - - logs->setChannelName(channelName); - - logsChannel = - app->twitch.server->getChannelOrEmpty(channelName); - } - - logs->setChannel(logsChannel); - - logs->getLogs(); - logs->setAttribute(Qt::WA_DeleteOnClose); - logs->show(); + channel->addMessage(makeSystemMessage( + "Online logs functionality has been removed. If you're a " + "moderator, you can use the /user command")); return ""; } else if (commandName == "/user") diff --git a/src/widgets/dialogs/LogsPopup.cpp b/src/widgets/dialogs/LogsPopup.cpp deleted file mode 100644 index 0afd6b9b4..000000000 --- a/src/widgets/dialogs/LogsPopup.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "LogsPopup.hpp" - -#include "IrcMessage" -#include "common/Channel.hpp" -#include "common/NetworkRequest.hpp" -#include "messages/Message.hpp" -#include "providers/twitch/TwitchChannel.hpp" -#include "providers/twitch/TwitchMessageBuilder.hpp" -#include "util/PostToThread.hpp" -#include "widgets/helper/ChannelView.hpp" - -#include -#include -#include -#include - -namespace chatterino { - -LogsPopup::LogsPopup() - : channel_(Channel::getEmpty()) -{ - this->resize(400, 600); -} - -void LogsPopup::setChannel(const ChannelPtr &channel) -{ - this->channel_ = channel; - this->updateWindowTitle(); -} - -void LogsPopup::setChannelName(const QString &channelName) -{ - this->channelName_ = channelName; - this->updateWindowTitle(); -} - -void LogsPopup::setTargetUserName(const QString &userName) -{ - this->userName_ = userName; - this->updateWindowTitle(); -} - -void LogsPopup::updateWindowTitle() -{ - this->setWindowTitle(this->userName_ + "'s logs in #" + this->channelName_); -} - -void LogsPopup::getLogs() -{ - if (this->channel_ && !this->channel_->isEmpty()) - { - if (auto twitchChannel = - dynamic_cast(this->channel_.get())) - { - this->channelName_ = twitchChannel->getName(); - this->getOverrustleLogs(); - - return; - } - } - - if (!this->channelName_.isEmpty()) - { - this->getOverrustleLogs(); - return; - } - - qDebug() << "Unable to get logs, no channel name or something specified"; -} - -void LogsPopup::setMessages(std::vector &messages) -{ - ChannelPtr logsChannel(new Channel("logs", Channel::Type::Misc)); - - logsChannel->addMessagesAtStart(messages); - SearchPopup::setChannel(logsChannel); -} - -void LogsPopup::getOverrustleLogs() -{ - auto url = - QString("https://overrustlelogs.net/api/v1/stalk/%1/%2.json?limit=500") - .arg(this->channelName_, this->userName_); - - NetworkRequest(url) - .caller(this) - .onError([this](NetworkResult) { - auto box = new QMessageBox( - QMessageBox::Information, "Error getting logs", - "No logs could be found for channel " + this->channelName_); - box->setWindowFlag(Qt::WindowStaysOnTopHint); - box->setAttribute(Qt::WA_DeleteOnClose); - box->show(); - box->raise(); - this->close(); - box->exec(); - }) - .onSuccess([this](auto result) -> Outcome { - auto data = result.parseJson(); - std::vector messages; - if (data.contains("lines")) - { - QJsonArray dataMessages = data.value("lines").toArray(); - for (auto i : dataMessages) - { - QJsonObject singleMessage = i.toObject(); - auto text = singleMessage.value("text").toString(); - QTime timeStamp = - QDateTime::fromSecsSinceEpoch( - singleMessage.value("timestamp").toInt()) - .time(); - - MessageBuilder builder; - builder.emplace(timeStamp); - builder.emplace(this->userName_, - MessageElementFlag::Username, - MessageColor::System); - builder.emplace(text, MessageElementFlag::Text, - MessageColor::Text); - builder.message().messageText = text; - builder.message().displayName = this->userName_; - messages.push_back(builder.release()); - } - } - messages.push_back( - MessageBuilder(systemMessage, - "Logs provided by https://overrustlelogs.net") - .release()); - this->setMessages(messages); - - return Success; - }) - .execute(); -} - -} // namespace chatterino diff --git a/src/widgets/dialogs/LogsPopup.hpp b/src/widgets/dialogs/LogsPopup.hpp deleted file mode 100644 index ab29ae431..000000000 --- a/src/widgets/dialogs/LogsPopup.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "widgets/helper/SearchPopup.hpp" - -namespace chatterino { - -class LogsPopup : public SearchPopup -{ -public: - LogsPopup(); - - void setChannel(const ChannelPtr &channel) override; - void setChannelName(const QString &channelName); - void setTargetUserName(const QString &userName); - - void getLogs(); - -protected: - void updateWindowTitle() override; - -private: - ChannelPtr channel_; - - QString userName_; - QString channelName_; - - void setMessages(std::vector &messages); - void getOverrustleLogs(); -}; - -} // namespace chatterino diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index c399f8ef1..3957c4216 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -13,7 +13,6 @@ #include "util/LayoutCreator.hpp" #include "util/PostToThread.hpp" #include "widgets/Label.hpp" -#include "widgets/dialogs/LogsPopup.hpp" #include "widgets/helper/EffectLabel.hpp" #include "widgets/helper/Line.hpp" @@ -113,8 +112,6 @@ UserInfoPopup::UserInfoPopup() user.emplace("Ignore").assign(&this->ui_.ignore); user.emplace("Ignore highlights") .assign(&this->ui_.ignoreHighlights); - auto viewLogs = user.emplace(this); - viewLogs->getLabel().setText("Online logs"); auto usercard = user.emplace(this); usercard->getLabel().setText("Usercard"); @@ -127,15 +124,6 @@ UserInfoPopup::UserInfoPopup() user->addStretch(1); - QObject::connect(viewLogs.getElement(), &Button::leftClicked, [this] { - auto logs = new LogsPopup(); - logs->setChannel(this->channel_); - logs->setTargetUserName(this->userName_); - logs->getLogs(); - logs->setAttribute(Qt::WA_DeleteOnClose); - logs->show(); - }); - QObject::connect(usercard.getElement(), &Button::leftClicked, [this] { QDesktopServices::openUrl("https://www.twitch.tv/popout/" + this->channel_->getName() + diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index 1200e3f59..0e3e2969f 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -43,7 +43,6 @@ private: struct { Button *avatarButton = nullptr; - // RippleEffectLabel2 *viewLogs = nullptr; Label *nameLabel = nullptr; Label *viewCountLabel = nullptr;