Ignore empty channel lists
This commit is contained in:
parent
8fa91ac470
commit
9581a63e81
@ -18,6 +18,7 @@ type ChannelListIndex interface {
|
|||||||
Finish()
|
Finish()
|
||||||
Search(q string) []*ChannelListItem
|
Search(q string) []*ChannelListItem
|
||||||
SearchN(q string, start, n int) []*ChannelListItem
|
SearchN(q string, start, n int) []*ChannelListItem
|
||||||
|
len() int
|
||||||
}
|
}
|
||||||
|
|
||||||
type MapChannelListIndex struct {
|
type MapChannelListIndex struct {
|
||||||
@ -74,6 +75,10 @@ func (idx *MapChannelListIndex) SearchN(q string, start, n int) []*ChannelListIt
|
|||||||
return res[start:min(start+n, len(res))]
|
return res[start:min(start+n, len(res))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (idx *MapChannelListIndex) len() int {
|
||||||
|
return len(idx.channels)
|
||||||
|
}
|
||||||
|
|
||||||
func min(x, y int) int {
|
func min(x, y int) int {
|
||||||
if x < y {
|
if x < y {
|
||||||
return x
|
return x
|
||||||
@ -142,6 +147,7 @@ func (m *ChannelIndexManager) Get(server string) (ChannelListIndex, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *ChannelIndexManager) Set(server string, index ChannelListIndex) {
|
func (m *ChannelIndexManager) Set(server string, index ChannelListIndex) {
|
||||||
|
if index.len() > 0 {
|
||||||
m.lock.Lock()
|
m.lock.Lock()
|
||||||
m.indexes[server] = &managedChannelIndex{
|
m.indexes[server] = &managedChannelIndex{
|
||||||
index: index,
|
index: index,
|
||||||
@ -149,6 +155,7 @@ func (m *ChannelIndexManager) Set(server string, index ChannelListIndex) {
|
|||||||
}
|
}
|
||||||
m.lock.Unlock()
|
m.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ChannelIndexManager) timeoutUpdate(server string) {
|
func (m *ChannelIndexManager) timeoutUpdate(server string) {
|
||||||
time.Sleep(ChannelListUpdateTimeout)
|
time.Sleep(ChannelListUpdateTimeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user