Adds Key()
This commit is contained in:
parent
3b336dc54b
commit
6b6086e389
3 changed files with 22 additions and 2 deletions
|
@ -28,3 +28,12 @@ type Channel struct {
|
|||
Author Author
|
||||
SubTitle SubTitle
|
||||
}
|
||||
|
||||
func (c *Channel) Key() string {
|
||||
switch {
|
||||
case len(c.Id) != 0:
|
||||
return c.Id
|
||||
default:
|
||||
return c.Title
|
||||
}
|
||||
}
|
||||
|
|
4
feed.go
4
feed.go
|
@ -171,13 +171,13 @@ func (this *Feed) makeFeed(doc *xmlx.Document) (err error) {
|
|||
func (this *Feed) notifyListeners() {
|
||||
var newchannels []*Channel
|
||||
for _, channel := range this.Channels {
|
||||
if this.database.request <- channel.Title; <-this.database.response {
|
||||
if this.database.request <- channel.Key(); !<-this.database.response {
|
||||
newchannels = append(newchannels, channel)
|
||||
}
|
||||
|
||||
var newitems []*Item
|
||||
for _, item := range channel.Items {
|
||||
if this.database.request <- item.Title; <-this.database.response {
|
||||
if this.database.request <- item.Key(); !<-this.database.response {
|
||||
newitems = append(newitems, item)
|
||||
}
|
||||
}
|
||||
|
|
11
item.go
11
item.go
|
@ -19,3 +19,14 @@ type Item struct {
|
|||
Contributors []string
|
||||
Content *Content
|
||||
}
|
||||
|
||||
func (i *Item) Key() string {
|
||||
switch {
|
||||
case i.Guid != nil && len(*i.Guid) != 0:
|
||||
return *i.Guid
|
||||
case len(i.Id) != 0:
|
||||
return i.Id
|
||||
default:
|
||||
return i.Title + i.PubDate
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue