diff --git a/app/models/spaz.db.js b/app/models/spaz.db.js index 4c94bd4..75c836a 100644 --- a/app/models/spaz.db.js +++ b/app/models/spaz.db.js @@ -65,6 +65,25 @@ Spaz.DB.markEntryAsRead = function(entryId) { } } +Spaz.DB.isRead = function(entryId) { + var conn = getSyncConnection(air.SQLMode.READ); + if (conn.connected) { + var sql = new air.SQLStatement(); + sql.text = "SELECT entry_id FROM read_entries WHERE entry_id=:entryId"; + sql.parameters[":entryId"] = entryId; + sql.sqlConnection = conn; + try { + sql.execute(); + return sql.getResult().data.length > 0 + } catch (error) { + Spaz.dump("Failed to find out if entry is read:", error); + return -1; + } + } + + return -1; +} + /* Check against the database if the entry should be marked as read or not. The first argument is the entry id which must * be an integer and the second argument is the callback function made once it has been determined if the entry should be marked as * read or not. The callback function takes as unique argument a boolean value which is true if the entry should be marked as read. diff --git a/app/views/spaz.timelines.js b/app/views/spaz.timelines.js index 3db7e70..e63eda4 100644 --- a/app/views/spaz.timelines.js +++ b/app/views/spaz.timelines.js @@ -223,6 +223,9 @@ var FriendsTimeline = function() { // convert emoticons data[i].text = Emoticons.SimpleSmileys.convertEmoticons(data[i].text) + // check if entry has been read + data[i].read = Spaz.DB.isRead(data[i].id); + if (data[i].SC_is_retweet) { // nl2br data[i].retweeted_status.text = sch.nl2br(data[i].retweeted_status.text); diff --git a/app/views/spaz.tpl.js b/app/views/spaz.tpl.js index fe4d1ac..5a723f4 100644 --- a/app/views/spaz.tpl.js +++ b/app/views/spaz.tpl.js @@ -18,13 +18,17 @@ Spaz.Tpl.parse =function(template, data) { if (!Spaz.Templates) Spaz.Templates = {}; Spaz.Templates.timeline_entry = function(d) { - d.isSent = (d.user.screen_name.toLowerCase() === Spaz.Prefs.getUser().toLowerCase()); d.SC_base_url = Spaz.Data.getBaseURL(); var entryHTML = ''; - entryHTML += '