Add setting to limit number of historical messages to load on connect (#2252)
This commit is contained in:
@@ -86,6 +86,7 @@
|
||||
# include <QShortcut>
|
||||
# include <QSizePolicy>
|
||||
# include <QSlider>
|
||||
# include <QSpinBox>
|
||||
# include <QStackedLayout>
|
||||
# include <QStandardPaths>
|
||||
# include <QString>
|
||||
|
||||
@@ -675,7 +675,13 @@ void TwitchChannel::loadRecentMessages()
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkRequest(Env::get().recentMessagesApiUrl.arg(this->getName()))
|
||||
auto baseURL = Env::get().recentMessagesApiUrl.arg(this->getName());
|
||||
|
||||
auto url = QString("%1?limit=%2")
|
||||
.arg(baseURL)
|
||||
.arg(getSettings()->twitchMessageHistoryLimit);
|
||||
|
||||
NetworkRequest(url)
|
||||
.onSuccess([weak = weakOf<Channel>(this)](auto result) -> Outcome {
|
||||
auto shared = weak.lock();
|
||||
if (!shared)
|
||||
|
||||
@@ -327,8 +327,14 @@ public:
|
||||
|
||||
IntSetting startUpNotification = {"/misc/startUpNotification", 0};
|
||||
QStringSetting currentVersion = {"/misc/currentVersion", ""};
|
||||
|
||||
BoolSetting loadTwitchMessageHistoryOnConnect = {
|
||||
"/misc/twitch/loadMessageHistoryOnConnect", true};
|
||||
IntSetting twitchMessageHistoryLimit = {
|
||||
"/misc/twitch/messageHistoryLimit",
|
||||
800,
|
||||
};
|
||||
|
||||
IntSetting emotesTooltipPreview = {"/misc/emotesTooltipPreview", 1};
|
||||
BoolSetting openLinksIncognito = {"/misc/openLinksIncognito", 0};
|
||||
|
||||
|
||||
@@ -600,6 +600,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
s.highlightInlineWhispers);
|
||||
layout.addCheckbox("Load message history on connect",
|
||||
s.loadTwitchMessageHistoryOnConnect);
|
||||
// TODO: Change phrasing to use better english once we can tag settings, right now it's kept as history instead of historical so that the setting shows up when the user searches for history
|
||||
layout.addIntInput("Max number of history messages to load on connect",
|
||||
s.twitchMessageHistoryLimit, 10, 800, 10);
|
||||
|
||||
layout.addCheckbox("Enable experimental IRC support (requires restart)",
|
||||
s.enableExperimentalIrc);
|
||||
|
||||
@@ -189,6 +189,43 @@ ColorButton *GeneralPageView::addColorButton(
|
||||
return colorButton;
|
||||
}
|
||||
|
||||
QSpinBox *GeneralPageView::addIntInput(const QString &text, IntSetting &setting,
|
||||
int min, int max, int step)
|
||||
{
|
||||
auto layout = new QHBoxLayout;
|
||||
|
||||
auto label = new QLabel(text + ":");
|
||||
|
||||
auto input = new QSpinBox;
|
||||
input->setMinimum(min);
|
||||
input->setMaximum(max);
|
||||
|
||||
// update when setting changes
|
||||
setting.connect(
|
||||
[input](const int &value, auto) {
|
||||
input->setValue(value);
|
||||
},
|
||||
this->managedConnections_);
|
||||
|
||||
// update setting on value changed
|
||||
QObject::connect(input, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
[&setting](int newValue) {
|
||||
setting = newValue;
|
||||
});
|
||||
|
||||
layout->addWidget(label);
|
||||
layout->addStretch(1);
|
||||
layout->addWidget(input);
|
||||
|
||||
this->addLayout(layout);
|
||||
|
||||
// groups
|
||||
this->groups_.back().widgets.push_back({input, {text}});
|
||||
this->groups_.back().widgets.push_back({label, {text}});
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void GeneralPageView::addNavigationSpacing()
|
||||
{
|
||||
this->navigationLayout_->addSpacing(24);
|
||||
|
||||
@@ -101,6 +101,8 @@ public:
|
||||
bool editable = false);
|
||||
ColorButton *addColorButton(const QString &text, const QColor &color,
|
||||
pajlada::Settings::Setting<QString> &setting);
|
||||
QSpinBox *addIntInput(const QString &text, IntSetting &setting, int min,
|
||||
int max, int step);
|
||||
void addNavigationSpacing();
|
||||
|
||||
template <typename OnClick>
|
||||
|
||||
Reference in New Issue
Block a user