updated nodejs package versions, work on article notification, some related nice fixes
This commit is contained in:
parent
26ba561c51
commit
8d288aae49
9 changed files with 80 additions and 19 deletions
|
@ -7,7 +7,6 @@
|
|||
#include "miscellaneous/iofactory.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QSqlError>
|
||||
#include <QSqlQuery>
|
||||
#include <QThread>
|
||||
|
|
|
@ -1654,13 +1654,6 @@ UpdatedArticles DatabaseQueries::updateMessages(const QSqlDatabase& db,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!msg->m_isRead) {
|
||||
updated_messages.m_unread.append(*msg);
|
||||
}
|
||||
|
||||
updated_messages.m_all.append(*msg);
|
||||
msg->m_insertedUpdated = true;
|
||||
|
||||
vals.append(QSL("\n(':feed', ':title', :is_read, :is_important, :is_deleted, "
|
||||
"':url', ':author', :score, :date_created, ':contents', ':enclosures', "
|
||||
"':custom_id', ':custom_hash', :account_id)")
|
||||
|
@ -1705,7 +1698,21 @@ UpdatedArticles DatabaseQueries::updateMessages(const QSqlDatabase& db,
|
|||
for (int l = i, c = 1; l < (i + batch_length); l++, c++) {
|
||||
Message* msg = msgs_to_insert[l];
|
||||
|
||||
if (msg->m_title.isEmpty()) {
|
||||
// This article was not for sure inserted. Tweak
|
||||
// next ID calculation.
|
||||
c--;
|
||||
continue;
|
||||
}
|
||||
|
||||
msg->m_insertedUpdated = true;
|
||||
msg->m_id = last_msg_id - batch_length + c;
|
||||
|
||||
if (!msg->m_isRead) {
|
||||
updated_messages.m_unread.append(*msg);
|
||||
}
|
||||
|
||||
updated_messages.m_all.append(*msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "gui/notifications/articlelistnotification.h"
|
||||
|
||||
#include "core/articlelistnotificationmodel.h"
|
||||
#include "database/databasequeries.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "network-web/webfactory.h"
|
||||
|
||||
|
@ -100,12 +101,44 @@ void ArticleListNotification::onMessageSelected(const QModelIndex& current, cons
|
|||
}
|
||||
|
||||
void ArticleListNotification::showFeed(int index) {
|
||||
m_model->setArticles(m_newMessages.value(m_ui.m_cmbFeeds->itemData(index).value<Feed*>()));
|
||||
m_model->setArticles(m_newMessages.value(selectedFeed()));
|
||||
onMessageSelected({}, {});
|
||||
}
|
||||
|
||||
void ArticleListNotification::openArticleInWebBrowser() {
|
||||
qApp->web()->openUrlInExternalBrowser(selectedMessage().m_url);
|
||||
Feed* fd = selectedFeed();
|
||||
Message msg = selectedMessage();
|
||||
|
||||
markAsRead(fd, {msg});
|
||||
qApp->web()->openUrlInExternalBrowser(msg.m_url);
|
||||
}
|
||||
|
||||
void ArticleListNotification::markAsRead(Feed* feed, const QList<Message>& articles) {
|
||||
ServiceRoot* acc = feed->getParentServiceRoot();
|
||||
QStringList message_ids;
|
||||
message_ids.reserve(articles.size());
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
for (const Message& message : articles) {
|
||||
message_ids.append(QString::number(message.m_id));
|
||||
}
|
||||
|
||||
if (acc->onBeforeSetMessagesRead(feed, articles, RootItem::ReadStatus::Read)) {
|
||||
auto db = qApp->database()->driver()->connection(metaObject()->className());
|
||||
|
||||
if (DatabaseQueries::markMessagesReadUnread(db, message_ids, RootItem::ReadStatus::Read)) {
|
||||
acc->onAfterSetMessagesRead(feed, articles, RootItem::ReadStatus::Read);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Feed* ArticleListNotification::selectedFeed(int index) const {
|
||||
if (index < 0) {
|
||||
return m_ui.m_cmbFeeds->currentData().value<Feed*>();
|
||||
}
|
||||
else {
|
||||
return m_ui.m_cmbFeeds->itemData(index).value<Feed*>();
|
||||
}
|
||||
}
|
||||
|
||||
Message ArticleListNotification::selectedMessage() const {
|
||||
|
|
|
@ -30,6 +30,9 @@ class ArticleListNotification : public BaseToastNotification {
|
|||
void openArticleInWebBrowser();
|
||||
|
||||
private:
|
||||
void markAsRead(Feed* feed, const QList<Message>& articles);
|
||||
|
||||
Feed* selectedFeed(int index = -1) const;
|
||||
Message selectedMessage() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -128,6 +128,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PlainToolButton" name="m_btnMarkAllRead">
|
||||
<property name="toolTip">
|
||||
<string>Open article in article list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -147,6 +161,7 @@
|
|||
<tabstop>m_btnNextPage</tabstop>
|
||||
<tabstop>m_btnOpenArticleList</tabstop>
|
||||
<tabstop>m_btnOpenWebBrowser</tabstop>
|
||||
<tabstop>m_btnMarkAllRead</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -9,12 +9,11 @@ class Settings;
|
|||
class QProcess;
|
||||
|
||||
class NodeJs : public QObject {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct PackageMetadata {
|
||||
public:
|
||||
|
||||
// Name of package.
|
||||
QString m_name;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <QProcess>
|
||||
|
||||
#define CLIQZ_ADBLOCKED_PACKAGE "@cliqz/adblocker"
|
||||
#define CLIQZ_ADBLOCKED_VERSION "1.23.5"
|
||||
#define CLIQZ_ADBLOCKED_VERSION "1.26.7"
|
||||
|
||||
class QUrl;
|
||||
class AdblockRequestInfo;
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#include <QDir>
|
||||
|
||||
#define READABILITY_PACKAGE "@mozilla/readability"
|
||||
#define READABILITY_VERSION "0.4.2"
|
||||
#define READABILITY_VERSION "0.4.4"
|
||||
|
||||
#define JSDOM_PACKAGE "jsdom"
|
||||
#define JSDOM_VERSION "19.0.0"
|
||||
#define JSDOM_VERSION "22.1.0"
|
||||
|
||||
Readability::Readability(QObject* parent) : QObject{parent}, m_modulesInstalling(false), m_modulesInstalled(false) {
|
||||
connect(qApp->nodejs(), &NodeJs::packageInstalledUpdated, this, &Readability::onPackageReady);
|
||||
|
@ -83,8 +83,8 @@ void Readability::makeHtmlReadable(const QString& html, const QString& base_url)
|
|||
.arg(QSL(APP_NAME)),
|
||||
QSystemTrayIcon::MessageIcon::Warning},
|
||||
{true, true, false});
|
||||
qApp->nodejs()->installPackages({{QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION)},
|
||||
{QSL(JSDOM_PACKAGE), QSL(JSDOM_VERSION)}});
|
||||
qApp->nodejs()->installUpdatePackages({{QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION)},
|
||||
{QSL(JSDOM_PACKAGE), QSL(JSDOM_VERSION)}});
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
qSetMessagePattern(QSL("time=\"%{time process}\" type=\"%{type}\" -> %{message}"));
|
||||
|
@ -57,6 +57,8 @@ int main(int argc, char* argv[]) {
|
|||
char** const av = argv;
|
||||
QStringList raw_cli_args;
|
||||
|
||||
raw_cli_args.reserve(argc);
|
||||
|
||||
for (int a = 0; a < argc; a++) {
|
||||
raw_cli_args << QString::fromLocal8Bit(av[a]);
|
||||
}
|
||||
|
@ -70,10 +72,13 @@ int main(int argc, char* argv[]) {
|
|||
QCoreApplication::setApplicationVersion(QSL(APP_VERSION));
|
||||
QCoreApplication::setOrganizationDomain(QSL(APP_URL));
|
||||
|
||||
qDebugNN << LOGSEC_CORE << "Starting" << NONQUOTE_W_SPACE_DOT(APP_LONG_NAME);
|
||||
qDebugNN << LOGSEC_CORE << "Current UTC date/time is"
|
||||
<< NONQUOTE_W_SPACE_DOT(QDateTime::currentDateTimeUtc().toString(Qt::DateFormat::ISODate));
|
||||
|
||||
// Instantiate base application object.
|
||||
Application application(QSL(APP_LOW_NAME), argc, argv, raw_cli_args);
|
||||
|
||||
qDebugNN << LOGSEC_CORE << "Starting" << NONQUOTE_W_SPACE_DOT(APP_LONG_NAME);
|
||||
qDebugNN << LOGSEC_CORE << "Instantiated class " << QUOTE_W_SPACE_DOT(application.metaObject()->className());
|
||||
|
||||
// Check if another instance is running.
|
||||
|
|
Loading…
Add table
Reference in a new issue