hook up feed subscription

This commit is contained in:
Zlatin Balevsky
2020-03-10 12:44:25 +00:00
parent ed04c40420
commit e70bec3a51
4 changed files with 26 additions and 1 deletions

View File

@@ -8,4 +8,5 @@ import com.muwire.core.Event
*/
class UIFeedConfigurationEvent extends Event {
Feed feed
boolean newFeed
}

View File

@@ -12,6 +12,8 @@ import javax.swing.JOptionPane
import com.muwire.core.Core
import com.muwire.core.Persona
import com.muwire.core.download.UIDownloadEvent
import com.muwire.core.filefeeds.Feed
import com.muwire.core.filefeeds.UIFeedConfigurationEvent
import com.muwire.core.search.UIResultEvent
import com.muwire.core.trust.TrustEvent
import com.muwire.core.trust.TrustLevel
@@ -109,7 +111,16 @@ class SearchTabController {
@ControllerAction
void subscribe() {
def sender = view.selectedSender()
if (sender == null)
return
Feed feed = new Feed(sender)
// TODO: defaults
feed.setUpdateInterval(60 * 1000)
core.eventBus.publish(new UIFeedConfigurationEvent(feed : feed, newFeed: true))
mvcGroup.parentGroup.view.showFeedsWindow.call()
}
@ControllerAction

View File

@@ -30,6 +30,7 @@ import com.muwire.core.download.Downloader
import com.muwire.core.filecert.CertificateCreatedEvent
import com.muwire.core.filefeeds.FeedFetchEvent
import com.muwire.core.filefeeds.FeedLoadedEvent
import com.muwire.core.filefeeds.UIFeedConfigurationEvent
import com.muwire.core.files.AllFilesLoadedEvent
import com.muwire.core.files.DirectoryUnsharedEvent
import com.muwire.core.files.DirectoryWatchedEvent
@@ -230,6 +231,7 @@ class MainFrameModel {
core.eventBus.register(CertificateCreatedEvent.class, this)
core.eventBus.register(FeedLoadedEvent.class, this)
core.eventBus.register(FeedFetchEvent.class, this)
core.eventBus.register(UIFeedConfigurationEvent.class, this)
core.muOptions.watchedKeywords.each {
core.eventBus.publish(new ContentControlEvent(term : it, regex: false, add: true))
@@ -681,4 +683,15 @@ class MainFrameModel {
view.refreshFeeds()
}
}
void onUIFeedConfigurationEvent(UIFeedConfigurationEvent e) {
if (!e.newFeed)
return
runInsideUIAsync {
if (feeds.contains(e.feed))
return
feeds << e.feed
view.refreshFeeds()
}
}
}

View File

@@ -444,7 +444,7 @@ class MainFrameView {
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "feeds-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list : model.feeds) {
closureColumn(header : "Publisher", type : String, read : {it.getPublisher()})
closureColumn(header : "Publisher", type : String, read : {it.getPublisher().getHumanReadableName()})
closureColumn(header : "Files", type : Integer, read : {model.core.feedManager.getFeedItems(it.getPublisher()).size()})
closureColumn(header : "Last Updated", type : Long, read : {it.getLastUpdated()})
closureColumn(header : "Status", type : String, read : {it.getStatus()})