Skip to content

Commit ebce80e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into chatterino7
2 parents 47ba3bc + 2b4ede1 commit ebce80e

File tree

7 files changed

+70
-37
lines changed

7 files changed

+70
-37
lines changed

.github/pull_request_template.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
In the case of a bug fix, please include steps to reproduce the bug so the pull request can be tested.
44
If this PR fixes an issue on GitHub, mention this here to automatically close it: "Fixes #1234.".
55
-->
6+
7+
<!--
8+
Leave this at the bottom
9+
10+
Co-authored-by: -
11+
Tested-by: -
12+
Reported-by: -
13+
Reviewed-by: -
14+
Parent-pr: -
15+
-->

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Minor: Added the ability to filter on messages by the author's external badges (example: `author.external_badges contains "chatterino:Top Donator"` or `author.external_badges contains "frankerfacez:bot"`). (#6709)
2828
- Minor: Added Markdown support to user notes. (#6490)
2929
- Minor: Moderators and VIPs in shared chats now show their channel badges. (#6653)
30+
- Minor: Removed guard from update checker when using a nightly release. (#6752)
3031
- Minor: Added message read/update methods to the `Channel` plugin API. (#6650)
3132
- Minor: Added a display name change event to `Channel` for plugins. (#6594)
3233
- Minor: Added action to reset `/watching`. (#6759)

src/singletons/Updates.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ void Updates::installUpdates()
153153
return;
154154
}
155155

156+
if (Version::instance().isNightly())
157+
{
158+
// Since Nightly builds can be installed in many different ways, we ask the user to download the update manually.
159+
QDesktopServices::openUrl(QUrl("https://chatterino.com/#downloads"));
160+
return;
161+
}
162+
156163
#ifdef Q_OS_MACOS
157164
QMessageBox *box = new QMessageBox(
158165
QMessageBox::Information, "Chatterino Update",
@@ -354,12 +361,6 @@ void Updates::checkForUpdates()
354361
return;
355362
}
356363

357-
// Disable updates if on nightly
358-
if (version.isNightly())
359-
{
360-
return;
361-
}
362-
363364
// See https://github.com/SevenTV/SevenTV/issues/48#issue-2193272289
364365
// for the proposed structure of the response.
365366
auto onSuccess = [this](const NetworkResult &result) {
@@ -531,6 +532,32 @@ bool Updates::isDowngrade() const
531532
return this->isDowngrade_;
532533
}
533534

535+
QString Updates::buildUpdateAvailableText() const
536+
{
537+
const auto &version = Version::instance();
538+
539+
if (version.isNightly())
540+
{
541+
// Since Nightly builds can be installed in many different ways, we ask the user to download the update manually.
542+
return QString("An update (%1) is available.\n\nDo you want to head to "
543+
"Chatterino.com to download the new update?")
544+
.arg(this->getOnlineVersion());
545+
}
546+
547+
if (this->isDowngrade())
548+
{
549+
return QString("The version online (%1) seems to be lower than the "
550+
"current (%2).\nEither a version was reverted or "
551+
"you are running a newer build.\n\nDo you want to "
552+
"download and install it?")
553+
.arg(this->getOnlineVersion(), this->getCurrentVersion());
554+
}
555+
556+
return QString("An update (%1) is available.\n\nDo you want to "
557+
"download and install it?")
558+
.arg(this->getOnlineVersion());
559+
}
560+
534561
void Updates::setStatus_(Status status)
535562
{
536563
if (this->status_ != status)

src/singletons/Updates.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class Updates
5959
bool isError() const;
6060
bool isDowngrade() const;
6161

62+
/// Generates the string that the update dialog will show.
63+
QString buildUpdateAvailableText() const;
64+
6265
pajlada::Signals::Signal<Status> statusUpdated;
6366

6467
private:

src/widgets/buttons/InitUpdateButton.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,10 @@ void initUpdateButton(PixmapButton &button,
3737
// be destroyed before the button is destroyed, since it is destroyed on focus loss
3838
//
3939
// The button is either attached to a Notebook, or a Window frame
40-
std::ignore =
41-
dialog->buttonClicked.connect([&button, relayout](auto buttonType) {
42-
switch (buttonType)
43-
{
44-
case UpdateDialog::Dismiss: {
45-
button.hide();
46-
relayout();
47-
}
48-
break;
49-
case UpdateDialog::Install: {
50-
getApp()->getUpdates().installUpdates();
51-
}
52-
break;
53-
}
54-
});
40+
std::ignore = dialog->dismissed.connect([&button, relayout]() {
41+
button.hide();
42+
relayout();
43+
});
5544

5645
// handle.reset(dialog);
5746
// dialog->closing.connect([&handle] { handle.release(); });

src/widgets/dialogs/UpdateDialog.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "widgets/dialogs/UpdateDialog.hpp"
66

77
#include "Application.hpp"
8+
#include "common/Version.hpp"
89
#include "singletons/Updates.hpp"
910
#include "util/LayoutCreator.hpp"
1011
#include "widgets/Label.hpp"
@@ -29,7 +30,17 @@ UpdateDialog::UpdateDialog()
2930
->setWordWrap(true);
3031

3132
auto buttons = layout.emplace<QDialogButtonBox>();
32-
auto *install = buttons->addButton("Install", QDialogButtonBox::AcceptRole);
33+
34+
const auto *installText = [] {
35+
if (Version::instance().isNightly())
36+
{
37+
return "Yes";
38+
}
39+
40+
return "Install";
41+
}();
42+
auto *install =
43+
buttons->addButton(installText, QDialogButtonBox::AcceptRole);
3344
this->ui_.installButton = install;
3445
auto *dismiss = buttons->addButton("Dismiss", QDialogButtonBox::RejectRole);
3546

@@ -38,7 +49,7 @@ UpdateDialog::UpdateDialog()
3849
this->close();
3950
});
4051
QObject::connect(dismiss, &QPushButton::clicked, this, [this] {
41-
this->buttonClicked.invoke(Dismiss);
52+
this->dismissed.invoke();
4253
this->close();
4354
});
4455

@@ -60,17 +71,7 @@ void UpdateDialog::updateStatusChanged(Updates::Status status)
6071
{
6172
case Updates::UpdateAvailable: {
6273
this->ui_.label->setText(
63-
(getApp()->getUpdates().isDowngrade()
64-
? QString(
65-
"The version online (%1) seems to be lower than the "
66-
"current (%2).\nEither a version was reverted or "
67-
"you are running a newer build.\n\nDo you want to "
68-
"download and install it?")
69-
.arg(getApp()->getUpdates().getOnlineVersion(),
70-
getApp()->getUpdates().getCurrentVersion())
71-
: QString("An update (%1) is available.\n\nDo you want to "
72-
"download and install it?")
73-
.arg(getApp()->getUpdates().getOnlineVersion())));
74+
getApp()->getUpdates().buildUpdateAvailableText());
7475
this->updateGeometry();
7576
}
7677
break;

src/widgets/dialogs/UpdateDialog.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ namespace chatterino {
1515

1616
class Label;
1717

18+
/// The UpdateDialog is what's shown to the user after they clicked the update indicator in the tab bar/title bar.
19+
///
20+
/// For Nightly builds, we change the "Install" text to "Yes" to better match the question posed by the available update.
1821
class UpdateDialog : public BaseWindow
1922
{
2023
public:
21-
enum Button { Dismiss, Install };
22-
2324
UpdateDialog();
2425

25-
pajlada::Signals::Signal<Button> buttonClicked;
26+
/// The user chose to dismiss this update.
27+
pajlada::Signals::NoArgSignal dismissed;
2628

2729
private:
2830
void updateStatusChanged(Updates::Status status);

0 commit comments

Comments
 (0)