Update RemoveBlockedUsers.plugin.js

This commit is contained in:
Mirco Wittrien 2022-03-10 16:01:50 +01:00
parent 7fb71dcbf4
commit c701ee6e97
1 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,7 @@
* @name RemoveBlockedUsers * @name RemoveBlockedUsers
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.3.9 * @version 1.4.0
* @description Removes blocked Messages/Users * @description Removes blocked Messages/Users
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,13 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "RemoveBlockedUsers", "name": "RemoveBlockedUsers",
"author": "DevilBro", "author": "DevilBro",
"version": "1.3.9", "version": "1.4.0",
"description": "Removes blocked Messages/Users" "description": "Removes blocked Messages/Users"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Console Log": "Fixed the Console Log Spam causing a Slow Down", "Offline List": "Fixed Issue where switching between servers would remove more and more users from the offline list if someone was blocked"
"Placeholder": "Fixed Placeholders appearing the the Member List for Blocked Users"
} }
} }
}; };
@ -352,13 +351,15 @@ module.exports = (_ => {
processChannelMembers (e) { processChannelMembers (e) {
if (this.settings.places.memberList) { if (this.settings.places.memberList) {
let hidden = 0, newRows = new Array(e.instance.props.rows.length), newGroups = new Array(e.instance.props.groups.length); let hiddenRows = 0, newRows = new Array(e.instance.props.rows.length), newGroups = new Array(e.instance.props.groups.length);
e.instance.props.groups = [].concat(e.instance.props.groups);
e.instance.props.rows = [].concat(e.instance.props.rows);
for (let i in e.instance.props.rows) { for (let i in e.instance.props.rows) {
let row = e.instance.props.rows[i]; let row = e.instance.props.rows[i];
if (!row || row.type != "MEMBER") newRows[i] = row; if (!row || row.type != "MEMBER") newRows[i] = row;
else if (!row.user || !BDFDB.LibraryModules.RelationshipStore.isBlocked(row.user.id)) newRows[i] = row; else if (!row.user || !BDFDB.LibraryModules.RelationshipStore.isBlocked(row.user.id)) newRows[i] = row;
else { else {
hidden++; hiddenRows++;
let found = false, rowIndex = i - 1; let found = false, rowIndex = i - 1;
while (!found && rowIndex > -1) { while (!found && rowIndex > -1) {
if (newRows[rowIndex] && newRows[rowIndex].type == "GROUP") { if (newRows[rowIndex] && newRows[rowIndex].type == "GROUP") {
@ -373,16 +374,14 @@ module.exports = (_ => {
} }
} }
} }
if (hidden) { if (hiddenRows) {
e.instance.props.groups = [].concat(e.instance.props.groups);
e.instance.props.rows = [].concat(e.instance.props.rows);
let indexSum = 0; let indexSum = 0;
for (let i in e.instance.props.groups) { for (let i in e.instance.props.groups) {
newGroups[i] = Object.assign({}, e.instance.props.groups[i], {index: indexSum}); newGroups[i] = Object.assign({}, e.instance.props.groups[i], {index: indexSum});
if (e.instance.props.groups[i].count > 0) indexSum += (e.instance.props.groups[i].count + 1); if (e.instance.props.groups[i].count > 0) indexSum += (e.instance.props.groups[i].count + 1);
} }
for (let i in newRows) if (newRows[i] && newRows[i].type == "GROUP" && newRows[i].count <= 0) { for (let i in newRows) if (newRows[i] && newRows[i].type == "GROUP" && newRows[i].count <= 0) {
hidden++; hiddenRows++;
newRows[i] = undefined; newRows[i] = undefined;
} }
const removeEmptyWithin = (array, filter) => { const removeEmptyWithin = (array, filter) => {