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 = {
list: [],
filter: null,
duplicates: true,
add(channel) {
this.list.push(channel)
},
@ -68,13 +69,30 @@ db.channels = {
break
}
} 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
return output
},
removeDuplicates() {
this.duplicates = false
return this
},
all() {
return this.list
},