Remove "Online Logs" functionality (#1649)

The /logs command will direct users to the /user command instead

Changelog has been updated to reflect this change
This commit is contained in:
pajlada
2020-05-02 06:18:35 -04:00
committed by GitHub
parent 08678628d5
commit b4eb56f362
7 changed files with 4 additions and 222 deletions
-136
View File
@@ -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 <QDateTime>
#include <QJsonArray>
#include <QMessageBox>
#include <QVBoxLayout>
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<TwitchChannel *>(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<MessagePtr> &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<MessagePtr> 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<TimestampElement>(timeStamp);
builder.emplace<TextElement>(this->userName_,
MessageElementFlag::Username,
MessageColor::System);
builder.emplace<TextElement>(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
-31
View File
@@ -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<MessagePtr> &messages);
void getOverrustleLogs();
};
} // namespace chatterino
-12
View File
@@ -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<QCheckBox>("Ignore").assign(&this->ui_.ignore);
user.emplace<QCheckBox>("Ignore highlights")
.assign(&this->ui_.ignoreHighlights);
auto viewLogs = user.emplace<EffectLabel2>(this);
viewLogs->getLabel().setText("Online logs");
auto usercard = user.emplace<EffectLabel2>(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() +
-1
View File
@@ -43,7 +43,6 @@ private:
struct {
Button *avatarButton = nullptr;
// RippleEffectLabel2 *viewLogs = nullptr;
Label *nameLabel = nullptr;
Label *viewCountLabel = nullptr;