mirror of https://github.com/zlatinb/muwire
add an IDLE status to feeds for display purposes
parent
a0cb214e2b
commit
e2a9db8056
|
@ -1,5 +1,5 @@
|
|||
package com.muwire.core.filefeeds;
|
||||
|
||||
public enum FeedFetchStatus {
|
||||
CONNECTING, FETCHING, FINISHED, FAILED
|
||||
IDLE, CONNECTING, FETCHING, FINISHED, FAILED
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue