add an IDLE status to feeds for display purposes

pull/42/head
Zlatin Balevsky 2020-03-10 07:32:45 +00:00
parent a0cb214e2b
commit e2a9db8056
3 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,5 @@
package com.muwire.core.filefeeds;
public enum FeedFetchStatus {
CONNECTING, FETCHING, FINISHED, FAILED
IDLE, CONNECTING, FETCHING, FINISHED, FAILED
}

View File

@ -77,6 +77,8 @@ class FeedManager {
feed.setItemsToKeep(parsed.itemsToKeep)
feed.setAutoDownload(parsed.autoDownload)
feed.setStatus(FeedFetchStatus.IDLE.name())
feeds.put(feed.getPublisher(), feed)
eventBus.publish(new FeedLoadedEvent(feed : feed))
@ -115,13 +117,19 @@ class FeedManager {
}
void onFeedFetchEvent(FeedFetchEvent e) {
if (e.status != FeedFetchStatus.FINISHED)
return
Feed feed = feeds.get(e.host)
if (feed == null) {
log.severe("Finished fetching non-existent feed " + e.host.getHumanReadableName())
return
}
feed.setStatus(e.status.name())
if (e.status != FeedFetchStatus.FINISHED)
return
feed.setStatus(FeedFetchStatus.IDLE.name())
feed.setLastUpdated(e.getTimestamp())
// save feed items, then save feed
persister.submit({saveFeedItems(e.host)} as Runnable)

View File

@ -10,6 +10,7 @@ public class Feed {
private long lastUpdated;
private int itemsToKeep;
private boolean autoDownload;
private String status;
public Feed(Persona publisher) {
this.publisher = publisher;
@ -51,4 +52,11 @@ public class Feed {
return publisher;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
}