Update db.js

This commit is contained in:
freearhey 2021-05-10 16:12:13 +03:00
parent dec8e25abb
commit ffd88ddc79
1 changed files with 19 additions and 1 deletions

View File

@ -32,6 +32,7 @@ db.load = function () {
db.channels = { db.channels = {
list: [], list: [],
filter: null, filter: null,
duplicates: true,
add(channel) { add(channel) {
this.list.push(channel) this.list.push(channel)
}, },
@ -68,13 +69,30 @@ db.channels = {
break break
} }
} else { } else {
output = this.all() output = this.list
} }
if (!this.duplicates) {
const buffer = []
output = output.filter(channel => {
const info = channel.getInfo()
if (buffer.includes(info)) return false
buffer.push(info)
return true
})
}
this.duplicates = true
this.filter = null this.filter = null
return output return output
}, },
removeDuplicates() {
this.duplicates = false
return this
},
all() { all() {
return this.list return this.list
}, },