remove duplicate dms

This commit is contained in:
Mystikfluu 2022-08-11 12:01:53 +02:00
parent 399933a803
commit 9a5b2c9385

View File

@ -337,6 +337,18 @@ function switchChannel(channelname) {
socket.send(JSON.stringify({"id":"switchChannel","data":channelname})) socket.send(JSON.stringify({"id":"switchChannel","data":channelname}))
} }
function removeDuplicates(a) {
let prims = {"boolean":{}, "number":{}, "string":{}}, objs = [];
return a.filter(function(item) {
let type = typeof item;
if(type in prims)
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
else
return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
}
async function loadChannels() { async function loadChannels() {
// <!-- <p class="channel">- Channel Name -</p> --> // <!-- <p class="channel">- Channel Name -</p> -->
@ -352,6 +364,8 @@ async function loadChannels() {
} }
} }
channels = removeDuplicates(channels)
let tab = document.getElementById("channelTab") let tab = document.getElementById("channelTab")
tab.innerHTML = "" tab.innerHTML = ""
for (let i = 0; i < channels.length; i++) { for (let i = 0; i < channels.length; i++) {