Skip to content

Commit

Permalink
chore: version 7.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jul 23, 2023
2 parents 13494dc + 852b367 commit 0f774c4
Show file tree
Hide file tree
Showing 17 changed files with 321 additions and 38 deletions.
11 changes: 11 additions & 0 deletions docs/_posts/2023-07-23-grabber-7-11-2-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "Grabber 7.11.2 released"
date: 2023-07-23 21:45 +0200
categories: release
---


Grabber 7.11.2 has been released.

The list of changes and download links can be found on Github:
<https://github.com/Bionus/imgbrd-grabber/releases/tag/v7.11.2>
2 changes: 1 addition & 1 deletion scripts/windows-setup/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

#ifndef MyAppVersion
# define MyAppVersion "7.11.1"
# define MyAppVersion "7.11.2"
#endif

#ifndef QtApngDll
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(TRACE)
endif()

if((NOT DEFINED VERSION) OR ((DEFINED NIGHTLY) AND (NIGHTLY MATCHES "1")))
set(VERSION "7.11.1")
set(VERSION "7.11.2")
else()
string(REGEX REPLACE "^v" "" VERSION "${VERSION}")
endif()
Expand Down
1 change: 1 addition & 0 deletions src/dist/linux/org.bionus.Grabber.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<url type="contribute">https://github.com/Bionus/imgbrd-grabber/blob/master/CONTRIBUTING.md</url>

<releases>
<release version="7.11.2" date="2023-07-23" />
<release version="7.11.1" date="2023-06-25" />
<release version="7.11.0" date="2023-06-05" />
<release version="7.10.1" date="2023-01-07" />
Expand Down
11 changes: 5 additions & 6 deletions src/gui/src/viewer/viewer-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ ViewerWindow::ViewerWindow(QList<QSharedPointer<Image>> images, const QSharedPoi
setStyleSheet("#ViewerWindow { background-color:" + bg + "; }");
}

m_resizeTimer = new QTimer(this);
connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(update()));
m_resizeTimer->setSingleShot(true);
connect(&m_resizeTimer, SIGNAL(timeout()), this, SLOT(update()));
m_resizeTimer.setSingleShot(true);

load(image);
}
Expand Down Expand Up @@ -1201,11 +1200,11 @@ void ViewerWindow::toggleSlideshow()

void ViewerWindow::resizeEvent(QResizeEvent *e)
{
if (!m_resizeTimer->isActive()) {
if (!m_resizeTimer.isActive()) {
m_timeout = qMin(500, qMax(50, (m_displayImage.width() * m_displayImage.height()) / 100000));
}
m_resizeTimer->stop();
m_resizeTimer->start(m_timeout);
m_resizeTimer.stop();
m_resizeTimer.start(m_timeout);
update(true);

QWidget::resizeEvent(e);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/viewer/viewer-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ViewerWindow : public QWidget
bool m_pendingClose;
bool m_tooBig, m_loadedImage, m_loadedDetails;
QAffiche *m_labelTagsTop, *m_labelTagsLeft;
QTimer *m_resizeTimer;
QTimer m_resizeTimer;
QElapsedTimer m_imageTime;
QString m_link;
bool m_finished;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/src/analytics.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "analytics.h"
#include <QCoreApplication>

class QString;
class QVariant;
Expand Down Expand Up @@ -62,6 +63,8 @@ void Analytics::sendScreenView(const QString& screenName, const QVariantMap& cus
QVariantMap eventParams(customValues);
eventParams["firebase_screen"] = screenName;
eventParams["firebase_screen_class"] = screenName;
eventParams["app_name"] = qApp->applicationName();
eventParams["app_version"] = qApp->applicationVersion();
m_ga4.sendEvent("screen_view", eventParams);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/src/downloader/image-downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void ImageDownloader::setSize(Image::Size size)
{
if (size == Image::Size::Unknown) {
const bool getOriginals = m_profile->getSettings()->value("Save/downloadoriginals", true).toBool();
const bool hasSample = m_image->url(Image::Size::Sample).isEmpty();
const bool hasSample = !m_image->url(Image::Size::Sample).isEmpty();
if (getOriginals || !hasSample) {
m_size = Image::Size::Full;
} else {
Expand Down
46 changes: 33 additions & 13 deletions src/lib/src/login/oauth2-login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ OAuth2Login::OAuth2Login(OAuth2Auth *auth, Site *site, NetworkManager *manager,
{
m_accessToken = m_settings->value("auth/accessToken").toString();
m_refreshToken = m_settings->value("auth/refreshToken").toString();
m_expires = m_settings->value("auth/accessTokenExpiration").toDateTime();
}

bool OAuth2Login::isTestable() const
Expand Down Expand Up @@ -200,8 +201,10 @@ void OAuth2Login::loginAuthorizationCode()

m_accessToken = flow->token();
m_refreshToken = flow->refreshToken();
m_expires = flow->expirationAt();
m_settings->setValue("auth/accessToken", m_accessToken);
m_settings->setValue("auth/refreshToken", m_refreshToken);
m_settings->setValue("auth/accessTokenExpiration", m_expires);

emit loggedIn(Result::Success);

Expand Down Expand Up @@ -300,19 +303,30 @@ void OAuth2Login::basicRefresh()

void OAuth2Login::refresh(bool login)
{
log(QStringLiteral("[%1] Refreshing OAuth2 token...").arg(m_site->url()), Logger::Info);
// Don't try to refresh while a refresh is already in progress
if (m_refreshing) {
if (login) {
m_refreshForLogin = true;
}
return;
}

const QString consumerKey = m_settings->value("auth/consumerKey").toString();
const QString consumerSecret = m_settings->value("auth/consumerSecret").toString();
log(QStringLiteral("[%1] Refreshing OAuth2 token...").arg(m_site->url()), Logger::Info);

// Without a refresh token, there's nothing to do
if (m_refreshToken.isEmpty()) {
log(QStringLiteral("[%1] Cannot refresh OAuth2 token without a refresh token").arg(m_site->url()), Logger::Warning);
if (login) {
emit loggedIn(Result::Failure);
}
m_refreshing = false;
return;
}

// Set the refresh status and block other refresh requests until this one is completed
m_refreshing = true;
m_refreshForLogin = login;

QNetworkRequest request(m_site->fixUrl(m_auth->tokenUrl()));
m_site->setRequestHeaders(request);

Expand All @@ -326,6 +340,8 @@ void OAuth2Login::refresh(bool login)
data = jsonDoc.toJson();
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
} else {
const QString consumerKey = m_settings->value("auth/consumerKey").toString();
const QString consumerSecret = m_settings->value("auth/consumerSecret").toString();
const QList<QStrP> body {
{ "grant_type", "refresh_token" },
{ "client_id", consumerKey },
Expand All @@ -344,16 +360,16 @@ void OAuth2Login::refresh(bool login)

// Post request and wait for a reply
m_refreshReply = m_manager->post(request, data);
if (login) {
connect(m_refreshReply, &NetworkReply::finished, this, &OAuth2Login::refreshLoginFinished);
} else {
connect(m_refreshReply, &NetworkReply::finished, this, &OAuth2Login::refreshFinished);
}
connect(m_refreshReply, &NetworkReply::finished, this, &OAuth2Login::refreshFinished);
}

void OAuth2Login::refreshLoginFinished()
void OAuth2Login::refreshFinished()
{
const bool ok = readResponse(m_refreshReply);
m_refreshing = false;
if (!m_refreshForLogin) {
return;
}
if (!ok) {
if (m_auth->authType() == "refresh_token") {
log(QStringLiteral("[%1] Refresh failed").arg(m_site->url()), Logger::Warning);
Expand All @@ -366,15 +382,13 @@ void OAuth2Login::refreshLoginFinished()
m_settings->remove("auth/accessToken");
m_refreshToken.clear();
m_settings->remove("auth/refreshToken");
m_expires = QDateTime();
m_settings->remove("auth/accessTokenExpiration");
login();
} else {
emit loggedIn(Result::Success);
}
}
void OAuth2Login::refreshFinished()
{
readResponse(m_refreshReply);
}

bool OAuth2Login::readResponse(NetworkReply *reply)
{
Expand Down Expand Up @@ -441,6 +455,7 @@ bool OAuth2Login::readResponse(NetworkReply *reply)
const int expiresSecond = QDateTime::currentDateTime().secsTo(m_expires);
QTimer::singleShot((expiresSecond / 2) * 1000, this, SIGNAL(basicRefresh()));
log(QStringLiteral("[%1] Token will expire at '%2'").arg(m_site->url(), m_expires.toString("yyyy-MM-dd HH:mm:ss")), Logger::Debug);
m_settings->setValue("auth/accessTokenExpiration", m_expires);
}
}

Expand All @@ -449,6 +464,11 @@ bool OAuth2Login::readResponse(NetworkReply *reply)

void OAuth2Login::complementRequest(QNetworkRequest *request) const
{
// Trigger a token refresh in the background if the token is expired
if (!m_refreshToken.isEmpty() && (!m_expires.isValid() || m_expires < QDateTime::currentDateTime())) {
const_cast<OAuth2Login*>(this)->refresh(false);
}

if (!m_accessToken.isEmpty()) {
request->setRawHeader("Authorization", "Bearer " + m_accessToken.toUtf8());
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/src/login/oauth2-login.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class OAuth2Login : public Login

protected slots:
void loginFinished();
void refreshLoginFinished();
void refreshFinished();
void basicRefresh();

Expand All @@ -54,6 +53,8 @@ class OAuth2Login : public Login
QString m_accessToken;
QString m_refreshToken;
QDateTime m_expires;
bool m_refreshing = false;
bool m_refreshForLogin = false;
};

#endif // OAUTH2_LOGIN_H
Loading

0 comments on commit 0f774c4

Please sign in to comment.