Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Add alwaysSetReadByID option to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
39aldo39 committed Nov 29, 2018
1 parent 5ce8d7e commit 4eb2972
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 9 deletions.
5 changes: 5 additions & 0 deletions plugins/backend/bazqux/bazquxInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ public class FeedReader.bazquxInterface : Peas.ExtensionBase, FeedServerInterfac
m_api.edidTag(articleID, "user/-/state/com.google/starred", false);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markAsRead(feedID);
Expand Down
11 changes: 11 additions & 0 deletions plugins/backend/demo/demoInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ public class FeedReader.demoInterface : Peas.ExtensionBase, FeedServerInterface

}

//--------------------------------------------------------------------------------------
// Should setArticleIsRead always be used instead of setFeedRead, setCategoryRead or
// markAllItemsRead?
// By using IDs as identifier, the articles are known, but it may be less efficient.
// If "true", the methods setFeedRead/setCategoryRead/markAllItemsRead never get called.
//--------------------------------------------------------------------------------------
public bool alwaysSetReadByID()
{

}


//--------------------------------------------------------------------------------------
// Mark all articles of the feed as read
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/feedbin/feedbinInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ public class FeedReader.FeedbinInterface : Peas.ExtensionBase, FeedServerInterfa
}
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feed_id)
{
setRead(feed_id, FeedListType.FEED);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/feedhq/feedhqInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ public class FeedReader.FeedHQInterface : Peas.ExtensionBase, FeedServerInterfac
m_api.edidTag(articleID, "user/-/state/com.google/starred", false);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markAsRead(feedID);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/feedly/feedlyInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public class FeedReader.feedlyInterface : Peas.ExtensionBase, FeedServerInterfac
}
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.mark_as_read(feedID, "feeds", ArticleStatus.READ);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/fresh/freshInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ public class FeedReader.freshInterface : Peas.ExtensionBase, FeedServerInterface
m_api.editTags(articleID, null, "user/-/state/com.google/starred");
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markAllAsRead(feedID);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/inoreader/InoReaderInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public class FeedReader.InoReaderInterface : Peas.ExtensionBase, FeedServerInter
m_api.edidTag(articleID, "user/-/state/com.google/starred", false);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markAsRead(feedID);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/local/localInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ public class FeedReader.localInterface : Peas.ExtensionBase, FeedServerInterface
return;
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/oldreader/oldreaderInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public class FeedReader.OldReaderInterface : Peas.ExtensionBase, FeedServerInter
m_api.edidTag(articleID, "user/-/state/com.google/starred", false);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markAsRead(feedID);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/owncloud/OwncloudNewsInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ public class FeedReader.OwncloudNewsInterface : Peas.ExtensionBase, FeedServerIn
m_api.updateArticleMarked(articleID, marked);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.markFeedRead(feedID, false);
Expand Down
5 changes: 5 additions & 0 deletions plugins/backend/ttrss/ttrssInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ public class FeedReader.ttrssInterface : Peas.ExtensionBase, FeedServerInterface
m_api.updateArticleMarked(int.parse(articleID), marked);
}

public bool alwaysSetReadByID()
{
return false;
}

public void setFeedRead(string feedID)
{
m_api.catchupFeed(feedID, false);
Expand Down
88 changes: 79 additions & 9 deletions src/Backend/Backend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,46 @@ namespace FeedReader {

public void markFeedAsRead(string feedID, bool isCat)
{
var useID = FeedServer.get_default().alwaysSetReadByID();
var articleIDs = "";
if(useID)
{
var listType = isCat ? FeedListType.CATEGORY : FeedListType.FEED;
var articles = DataBase.readOnly().read_articles(feedID, listType, ArticleListState.UNREAD, "", -1);
foreach (var article in articles)
{
articleIDs += "," + article.getArticleID();
}
if (articleIDs != "")
{
articleIDs = articleIDs.substring(1);
}
}

if(isCat)
{
if(m_offline)
{
CachedActionManager.get_default().markCategoryRead(feedID);
if(useID)
CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
CachedActionManager.get_default().markCategoryRead(feedID);
}
else
{
if(m_cacheSync)
ActionCache.get_default().markCategoryRead(feedID);
asyncPayload pl = () => { FeedServer.get_default().setCategoryRead(feedID); };
{
if(useID)
ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
ActionCache.get_default().markCategoryRead(feedID);
}
asyncPayload pl = () => {
if(useID)
FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ);
else
FeedServer.get_default().setCategoryRead(feedID);
};
callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); });
}

Expand All @@ -531,13 +560,26 @@ namespace FeedReader {
{
if(m_offline)
{
CachedActionManager.get_default().markFeedRead(feedID);
if(useID)
CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
CachedActionManager.get_default().markFeedRead(feedID);
}
else
{
if(m_cacheSync)
ActionCache.get_default().markFeedRead(feedID);
asyncPayload pl = () => { FeedServer.get_default().setFeedRead(feedID); };
{
if(useID)
ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
ActionCache.get_default().markFeedRead(feedID);
}
asyncPayload pl = () => {
if(useID)
FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ);
else
FeedServer.get_default().setFeedRead(feedID);
};
callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); });
}

Expand All @@ -553,15 +595,43 @@ namespace FeedReader {

public void markAllItemsRead()
{
var useID = FeedServer.get_default().alwaysSetReadByID();
var articleIDs = "";
if(useID)
{
var articles = DataBase.readOnly().read_articles(FeedID.ALL.to_string(), FeedListType.FEED, ArticleListState.UNREAD, "", -1);
foreach (var article in articles)
{
articleIDs += "," + article.getArticleID();
}
if (articleIDs != "")
{
articleIDs = articleIDs.substring(1);
}
}

if(m_offline)
{
CachedActionManager.get_default().markAllRead();
if(useID)
CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
CachedActionManager.get_default().markAllRead();
}
else
{
if(m_cacheSync)
ActionCache.get_default().markAllRead();
asyncPayload pl = () => { FeedServer.get_default().markAllItemsRead(); };
{
if(useID)
ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ);
else
ActionCache.get_default().markAllRead();
}
asyncPayload pl = () => {
if(useID)
FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ);
else
FeedServer.get_default().markAllItemsRead();
};
callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); });
}

Expand Down
8 changes: 8 additions & 0 deletions src/Backend/FeedServer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,14 @@ public class FeedReader.FeedServer : GLib.Object {
m_plugin.setArticleIsMarked(articleID, marked);
}

public bool alwaysSetReadByID()
{
if(!m_pluginLoaded)
return false;

return m_plugin.alwaysSetReadByID();
}

public void setFeedRead(string feedID)
{
if(!m_pluginLoaded)
Expand Down
2 changes: 2 additions & 0 deletions src/Backend/FeedServerInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public interface FeedReader.FeedServerInterface : GLib.Object {

public abstract bool logout();

public abstract bool alwaysSetReadByID();

public abstract void setArticleIsRead(string articleIDs, ArticleStatus read);

public abstract void setArticleIsMarked(string articleID, ArticleStatus marked);
Expand Down

0 comments on commit 4eb2972

Please sign in to comment.