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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 222 deletions

View file

@ -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

View file

@ -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 \

View file

@ -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 <QApplication>
@ -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<Channel> 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")

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

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

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() +

View file

@ -43,7 +43,6 @@ private:
struct {
Button *avatarButton = nullptr;
// RippleEffectLabel2 *viewLogs = nullptr;
Label *nameLabel = nullptr;
Label *viewCountLabel = nullptr;