Adds Key()
This commit is contained in:
parent
3b336dc54b
commit
6b6086e389
|
@ -28,3 +28,12 @@ type Channel struct {
|
||||||
Author Author
|
Author Author
|
||||||
SubTitle SubTitle
|
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() {
|
func (this *Feed) notifyListeners() {
|
||||||
var newchannels []*Channel
|
var newchannels []*Channel
|
||||||
for _, channel := range this.Channels {
|
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)
|
newchannels = append(newchannels, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
var newitems []*Item
|
var newitems []*Item
|
||||||
for _, item := range channel.Items {
|
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)
|
newitems = append(newitems, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
item.go
11
item.go
|
@ -19,3 +19,14 @@ type Item struct {
|
||||||
Contributors []string
|
Contributors []string
|
||||||
Content *Content
|
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…
Reference in New Issue