From ffd88ddc7970f04d21b64ed096487e586550921d Mon Sep 17 00:00:00 2001 From: freearhey Date: Mon, 10 May 2021 16:12:13 +0300 Subject: [PATCH] Update db.js --- scripts/db.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/db.js b/scripts/db.js index e4072cbd09..75cf792ff7 100644 --- a/scripts/db.js +++ b/scripts/db.js @@ -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 },