Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jangernert/FeedReader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lukas Gernert <jangernert@gmail.com>2018-01-18 03:03:21 +0300
committerJan Lukas Gernert <jangernert@gmail.com>2018-01-18 03:03:21 +0300
commitdd3ded79d7197df45a093e06193d93c69d8232e3 (patch)
treef7de5133e9fc328861e336e80377f05f4441daa1
parent5e7b47714b701910168ac5601d81baaf7cafca63 (diff)
only show notification if the newly added articles during last sync contain at least 1 unread article - fix #626
-rw-r--r--src/Backend/FeedServer.vala3
-rw-r--r--src/DataBaseReadOnly.vala11
-rw-r--r--src/Notification.vala8
-rw-r--r--src/SQLite.vala10
4 files changed, 22 insertions, 10 deletions
diff --git a/src/Backend/FeedServer.vala b/src/Backend/FeedServer.vala
index 1582a483..e9d48c3d 100644
--- a/src/Backend/FeedServer.vala
+++ b/src/Backend/FeedServer.vala
@@ -248,12 +248,13 @@ public class FeedReader.FeedServer : GLib.Object {
//update fulltext table
DataBase.writeAccess().updateFTS();
+ int new_and_unread = DataBase.readOnly().get_new_unread_count(row_id != null ? int.parse(row_id) : 0);
row_id = DataBase.readOnly().getMaxID("articles", "rowid");
int after = row_id != null ? int.parse(row_id) : 0;
int newArticles = after-before;
if(newArticles > 0)
{
- Notification.send(newArticles);
+ Notification.send(newArticles, new_and_unread);
}
var drop_weeks = drop_articles.to_weeks();
diff --git a/src/DataBaseReadOnly.vala b/src/DataBaseReadOnly.vala
index 00a0030d..81ca56cf 100644
--- a/src/DataBaseReadOnly.vala
+++ b/src/DataBaseReadOnly.vala
@@ -187,6 +187,17 @@ public class FeedReader.DataBaseReadOnly : GLib.Object {
return count_status_uncategorized(ArticleStatus.MARKED);
}
+ public int get_new_unread_count(int row_id)
+ {
+ if(row_id == 0)
+ return 0;
+
+ string query = "SELECT count(*) FROM articles WHERE unread = ? AND rowid > ?";
+ var rows = m_db.execute(query, { ArticleStatus.UNREAD, row_id });
+ assert(rows.size == 1 && rows[0].size == 1);
+ return rows[0][0].to_int();
+ }
+
public int getTagColor()
{
var rows = m_db.execute("SELECT COUNT(*) FROM tags WHERE instr(tagID, \"global.\") = 0");
diff --git a/src/Notification.vala b/src/Notification.vala
index f2919b4e..79890e3b 100644
--- a/src/Notification.vala
+++ b/src/Notification.vala
@@ -15,18 +15,18 @@
public class FeedReader.Notification : GLib.Object {
- public static void send(uint newArticles)
+ public static void send(uint new_articles, int new_and_unread)
{
string message = "";
string summary = _("New articles");
uint unread = DataBase.readOnly().get_unread_total();
- if(newArticles > 0)
+ if(new_articles > 0 && new_and_unread > 0)
{
- if(newArticles == 1)
+ if(new_articles == 1)
message = _("There is 1 new article (%u unread)").printf(unread);
else
- message = _("There are %u new articles (%u unread)").printf(newArticles, unread);
+ message = _("There are %u new articles (%u unread)").printf(new_articles, unread);
var notification = new GLib.Notification(summary);
notification.set_body(message);
diff --git a/src/SQLite.vala b/src/SQLite.vala
index 860a16c6..0f759ba7 100644
--- a/src/SQLite.vala
+++ b/src/SQLite.vala
@@ -75,7 +75,7 @@ public class FeedReader.SQLite : GLib.Object {
}
}
- public Gee.List<Gee.List<Sqlite.Value?>> execute(string query, Value?[]? params = null)
+ public Gee.List<Gee.List<Sqlite.Value?>> execute(string query, GLib.Value?[]? params = null)
{
Sqlite.Statement stmt;
int rc = m_db.prepare_v2(query, query.length, out stmt);
@@ -98,19 +98,19 @@ public class FeedReader.SQLite : GLib.Object {
// string
if(param.holds(typeof(float)) || param.holds(typeof(double)))
{
- var as_double = Value(typeof(double));
+ var as_double = GLib.Value(typeof(double));
param.transform(ref as_double);
stmt.bind_double(i, (double)as_double);
}
- else if(Value.type_transformable(param.type(), typeof(int64)))
+ else if(GLib.Value.type_transformable(param.type(), typeof(int64)))
{
- var as_int = Value(typeof(int64));
+ var as_int = GLib.Value(typeof(int64));
param.transform(ref as_int);
stmt.bind_int64(i, (int64)as_int);
}
else
{
- var as_string = Value(typeof(string));
+ var as_string = GLib.Value(typeof(string));
param.transform(ref as_string);
stmt.bind_text(i, (string)as_string);
}