stuff
This commit is contained in:
parent
7a8799fd0e
commit
d1e91cf42d
|
@ -750,7 +750,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.ObjectUtils.extract = function (obj, ...keys) {
|
||||
let newobj = {};
|
||||
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat().filter(n => n)) if (obj[key]) newobj[key] = obj[key];
|
||||
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat(10).filter(n => n)) if (obj[key]) newobj[key] = obj[key];
|
||||
return newobj;
|
||||
};
|
||||
BDFDB.ObjectUtils.exclude = function (obj, ...keys) {
|
||||
|
@ -759,7 +759,7 @@ var BDFDB = {
|
|||
return newobj;
|
||||
};
|
||||
BDFDB.ObjectUtils.delete = function (obj, ...keys) {
|
||||
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat().filter(n => n)) delete obj[key];
|
||||
if (BDFDB.ObjectUtils.is(obj)) for (let key of keys.flat(10).filter(n => n)) delete obj[key];
|
||||
};
|
||||
BDFDB.ObjectUtils.sort = function (obj, sort, except) {
|
||||
if (!BDFDB.ObjectUtils.is(obj)) return {};
|
||||
|
@ -988,7 +988,7 @@ var BDFDB = {
|
|||
const pluginname = typeof plugin === "string" ? plugin : plugin.name;
|
||||
const pluginid = pluginname.toLowerCase();
|
||||
if (!module.BDFDBpatch) module.BDFDBpatch = {};
|
||||
modulefunctions = [modulefunctions].flat().filter(n => n);
|
||||
modulefunctions = [modulefunctions].flat(10).filter(n => n);
|
||||
for (let modulefunction of modulefunctions) {
|
||||
if (!module[modulefunction]) module[modulefunction] = _ => {};
|
||||
const originalfunction = module[modulefunction];
|
||||
|
@ -1045,7 +1045,7 @@ var BDFDB = {
|
|||
if (!BDFDB.ObjectUtils.is(module) || !module.BDFDBpatch) return;
|
||||
const pluginname = !plugin ? null : (typeof plugin === "string" ? plugin : plugin.name).toLowerCase();
|
||||
if (modulefunctions) {
|
||||
for (let modulefunction of [modulefunctions].flat().filter(n => n)) if (module[modulefunction] && module.BDFDBpatch[modulefunction]) unpatch(modulefunction, pluginname);
|
||||
for (let modulefunction of [modulefunctions].flat(10).filter(n => n)) if (module[modulefunction] && module.BDFDBpatch[modulefunction]) unpatch(modulefunction, pluginname);
|
||||
}
|
||||
else for (let patchedfunction of module.BDFDBpatch) unpatch(patchedfunction, pluginname);
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ var BDFDB = {
|
|||
if (app) {
|
||||
let filteredmodules = [], patchtypes = {};
|
||||
for (let patchtype in plugin.patchedModules) for (let type in plugin.patchedModules[patchtype]) {
|
||||
let methodnames = [plugin.patchedModules[patchtype][type]].flat().filter(n => n);
|
||||
let methodnames = [plugin.patchedModules[patchtype][type]].flat(10).filter(n => n);
|
||||
if (methodnames.includes("componentDidMount") || methodnames.includes("componentDidUpdate") || methodnames.includes("render")) {
|
||||
filteredmodules.push(type);
|
||||
let unmappedtype = type.split(" _ _ ")[0];
|
||||
|
@ -1078,7 +1078,7 @@ var BDFDB = {
|
|||
patchtypes[unmappedtype].push(patchtype);
|
||||
}
|
||||
}
|
||||
selectedtypes = [selectedtypes].flat().filter(n => n);
|
||||
selectedtypes = [selectedtypes].flat(10).filter(n => n);
|
||||
if (selectedtypes.length) {
|
||||
selectedtypes = selectedtypes.map(type => type && WebModulesData.Patchmap[type] ? WebModulesData.Patchmap[type] + " _ _ " + type : type);
|
||||
filteredmodules = filteredmodules.filter(type => selectedtypes.indexOf(type) > -1);
|
||||
|
@ -1086,12 +1086,12 @@ var BDFDB = {
|
|||
filteredmodules = BDFDB.ArrayUtils.removeCopies(filteredmodules);
|
||||
if (filteredmodules.length) {
|
||||
try {
|
||||
const appinsdown = BDFDB.ReactUtils.findOwner(app, {name:filteredmodules, all:true, noCopies:true, group:true, unlimited:true});
|
||||
const appinsup = BDFDB.ReactUtils.findOwner(app, {name:filteredmodules, all:true, noCopies:true, group:true, unlimited:true, up:true});
|
||||
const appinsdown = BDFDB.ReactUtils.findOwner(app, {name:filteredmodules, all:true, group:true, unlimited:true});
|
||||
const appinsup = BDFDB.ReactUtils.findOwner(app, {name:filteredmodules, all:true, group:true, unlimited:true, up:true});
|
||||
for (let type in appinsdown) for (let ins of appinsdown[type]) InternalBDFDB.forceInitiateProcess(plugin, ins, type, patchtypes[type]);
|
||||
for (let type in appinsup) for (let ins of appinsup[type]) InternalBDFDB.forceInitiateProcess(plugin, ins, type, patchtypes[type]);
|
||||
if (bdsettings) {
|
||||
const bdsettingsins = BDFDB.ReactUtils.findOwner(bdsettings, {name:filteredmodules, all:true, noCopies:true, group:true, unlimited:true});
|
||||
const bdsettingsins = BDFDB.ReactUtils.findOwner(bdsettings, {name:filteredmodules, all:true, group:true, unlimited:true});
|
||||
for (let type in bdsettingsins) for (let ins of bdsettingsins[type]) InternalBDFDB.forceInitiateProcess(plugin, ins, type, patchtypes[type]);
|
||||
}
|
||||
}
|
||||
|
@ -1104,7 +1104,7 @@ var BDFDB = {
|
|||
if (!plugin || !instance || !type) return;
|
||||
let methodnames = [];
|
||||
for (let patchtype in plugin.patchedModules) if (plugin.patchedModules[patchtype][type]) methodnames.push(plugin.patchedModules[patchtype][type]);
|
||||
methodnames = BDFDB.ArrayUtils.removeCopies(methodnames).flat().filter(n => n);
|
||||
methodnames = BDFDB.ArrayUtils.removeCopies(methodnames).flat(10).filter(n => n);
|
||||
if (methodnames.includes("componentDidMount")) InternalBDFDB.initiateProcess(plugin, type, {instance, methodname:"componentDidMount", patchtypes});
|
||||
if (methodnames.includes("render")) BDFDB.ReactUtils.forceUpdate(instance);
|
||||
else if (methodnames.includes("componentDidUpdate")) InternalBDFDB.initiateProcess(plugin, type, {instance, methodname:"componentDidUpdate", patchtypes});
|
||||
|
@ -1332,7 +1332,7 @@ var BDFDB = {
|
|||
}
|
||||
if (e.thisObject.props.message && !e.thisObject.props.target) {
|
||||
const messageswrap = document.querySelector(BDFDB.dotCN.messages);
|
||||
if (messageswrap) for (let message of BDFDB.ReactUtils.findOwner(messageswrap, {name:"Message", all:true, noCopies:true, unlimited:true})) {
|
||||
if (messageswrap) for (let message of BDFDB.ReactUtils.findOwner(messageswrap, {name:"Message", all:true, unlimited:true})) {
|
||||
if (e.thisObject.props.message.id == message.props.message.id) {
|
||||
target = BDFDB.ReactUtils.findDOMNode(message);
|
||||
if (target) e.thisObject.props.target = target
|
||||
|
@ -1388,7 +1388,7 @@ var BDFDB = {
|
|||
LibraryModules.InviteUtils = BDFDB.ModuleUtils.findByProperties("acceptInvite", "createInvite");
|
||||
LibraryModules.KeyCodeUtils = Object.assign({}, BDFDB.ModuleUtils.findByProperties("toCombo", "keyToCode"));
|
||||
LibraryModules.KeyCodeUtils.getString = keyarray => {
|
||||
return LibraryModules.KeyCodeUtils.toString([keyarray].flat().filter(n => n).map(keycode => [BDFDB.DiscordConstants.KeyboardDeviceTypes.KEYBOARD_KEY, keycode, BDFDB.DiscordConstants.KeyboardEnvs.BROWSER]), true);
|
||||
return LibraryModules.KeyCodeUtils.toString([keyarray].flat(10).filter(n => n).map(keycode => [BDFDB.DiscordConstants.KeyboardDeviceTypes.KEYBOARD_KEY, keycode, BDFDB.DiscordConstants.KeyboardEnvs.BROWSER]), true);
|
||||
};
|
||||
LibraryModules.KeyEvents = BDFDB.ModuleUtils.findByProperties("aliases", "code", "codes");
|
||||
LibraryModules.LanguageStore = BDFDB.ModuleUtils.findByProperties("getLanguages", "Messages");
|
||||
|
@ -1472,9 +1472,9 @@ var BDFDB = {
|
|||
if (!nodeOrInstance || !BDFDB.ObjectUtils.is(config) || !config.name && !config.key && !config.props && !config.filter) return [null, -1];
|
||||
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
|
||||
if (!BDFDB.ObjectUtils.is(instance) && !BDFDB.ArrayUtils.is(instance)) return [null, -1];
|
||||
config.name = config.name && [config.name].flat().filter(n => n);
|
||||
config.key = config.key && [config.key].flat().filter(n => n);
|
||||
config.props = config.props && [config.props].flat().filter(n => n);
|
||||
config.name = config.name && [config.name].flat(10).filter(n => n);
|
||||
config.key = config.key && [config.key].flat(10).filter(n => n);
|
||||
config.props = config.props && [config.props].flat(10).filter(n => n);
|
||||
config.filter = typeof config.filter == "function" && config.filter;
|
||||
var parent = firstarray = instance;
|
||||
while (!BDFDB.ArrayUtils.is(firstarray) && firstarray.props && firstarray.props.children) firstarray = firstarray.props.children;
|
||||
|
@ -1536,9 +1536,9 @@ var BDFDB = {
|
|||
if (!nodeOrInstance || !config.name && !config.key && !config.props) return config.all ? (config.group ? {} : []) : null;
|
||||
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
|
||||
if (!BDFDB.ObjectUtils.is(instance)) return config.all ? (config.group ? {} : []) : null;
|
||||
config.name = config.name && [config.name].flat().filter(n => n);
|
||||
config.key = config.key && [config.key].flat().filter(n => n);
|
||||
config.props = config.props && [config.props].flat().filter(n => n);
|
||||
config.name = config.name && [config.name].flat(10).filter(n => n);
|
||||
config.key = config.key && [config.key].flat(10).filter(n => n);
|
||||
config.props = config.props && [config.props].flat(10).filter(n => n);
|
||||
var depth = -1;
|
||||
var start = performance.now();
|
||||
var maxdepth = config.unlimited ? 999999999 : (config.depth === undefined ? 30 : config.depth);
|
||||
|
@ -1563,7 +1563,7 @@ var BDFDB = {
|
|||
if (instance.stateNode && !Node.prototype.isPrototypeOf(instance.stateNode) && (instance.type && config.name && config.name.some(name => (instance.type.displayName || instance.type.name) === name.split(" _ _ ")[0]) || config.key && config.key.some(key => instance.key == key) || props && config.props && config.props.every(prop => BDFDB.ArrayUtils.is(prop) ? (BDFDB.ArrayUtils.is(prop[1]) ? prop[1].some(checkvalue => BDFDB.equals(props[prop[0]], checkvalue)) : BDFDB.equals(props[prop[0]], prop[1])) : props[prop] !== undefined))) {
|
||||
if (config.all === undefined || !config.all) result = instance.stateNode;
|
||||
else if (config.all) {
|
||||
if (config.noCopies === undefined || !config.noCopies || config.noCopies && !instance.stateNode.BDFDBreactSearch) {
|
||||
if (!instance.stateNode.BDFDBreactSearch) {
|
||||
instance.stateNode.BDFDBreactSearch = true;
|
||||
if (config.group) {
|
||||
if (config.name && instance.type && (instance.type.displayName || instance.type.name)) {
|
||||
|
@ -1597,8 +1597,8 @@ var BDFDB = {
|
|||
if (!nodeOrInstance || !config.name && !config.key) return null;
|
||||
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
|
||||
if (!BDFDB.ObjectUtils.is(instance)) return null;
|
||||
config.name = config.name && [config.name].flat().filter(n => n);
|
||||
config.key = config.key && [config.key].flat().filter(n => n);
|
||||
config.name = config.name && [config.name].flat(10).filter(n => n);
|
||||
config.key = config.key && [config.key].flat(10).filter(n => n);
|
||||
var depth = -1;
|
||||
var start = performance.now();
|
||||
var maxdepth = config.unlimited ? 999999999 : (config.depth === undefined ? 30 : config.depth);
|
||||
|
@ -1688,7 +1688,7 @@ var BDFDB = {
|
|||
}
|
||||
};
|
||||
BDFDB.ReactUtils.forceUpdate = function (...instances) {
|
||||
for (let ins of instances.flat().filter(n => n)) if (ins.updater && typeof ins.updater.isMounted == "function" && ins.updater.isMounted(ins)) ins.forceUpdate();
|
||||
for (let ins of instances.flat(10).filter(n => n)) if (ins.updater && typeof ins.updater.isMounted == "function" && ins.updater.isMounted(ins)) ins.forceUpdate();
|
||||
};
|
||||
BDFDB.ReactUtils.getInstance = function (node) {
|
||||
if (!BDFDB.ObjectUtils.is(node)) return null;
|
||||
|
@ -1825,7 +1825,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.GuildUtils.getAll = function () {
|
||||
var found = [], objs = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:["Guild","GuildIcon"], all:true, noCopies:true, unlimited:true})) {
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:["Guild","GuildIcon"], all:true, unlimited:true})) {
|
||||
if (ins.props && ins.props.guild) objs.push(Object.assign(new ins.props.guild.constructor(ins.props.guild), {div:ins.handleContextMenu ? BDFDB.ReactUtils.findDOMNode(ins) : BDFDB.GuildUtils.createCopy(ins.props.guild), instance:ins}));
|
||||
}
|
||||
for (let id of BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds()) {
|
||||
|
@ -2013,7 +2013,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.FolderUtils.getAll = function () {
|
||||
var found = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guildswrapper), {name:"GuildFolder", all:true, noCopies:true, unlimited:true})) {
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guildswrapper), {name:"GuildFolder", all:true, unlimited:true})) {
|
||||
if (ins.props && ins.props.folderId) found.push(Object.assign({}, ins.props, {div:BDFDB.ReactUtils.findDOMNode(ins), instance:ins}));
|
||||
}
|
||||
return found;
|
||||
|
@ -2041,7 +2041,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.ChannelUtils.getAll = function () {
|
||||
var found = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.channels), {name: ["ChannelCategoryItem", "ChannelItem", "PrivateChannel"], all:true, noCopies:true, unlimited:true})) if (ins.props && !ins.props.ispin && ins.props.channel && ins._reactInternalFiber.return) {
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.channels), {name: ["ChannelCategoryItem", "ChannelItem", "PrivateChannel"], all:true, unlimited:true})) if (ins.props && !ins.props.ispin && ins.props.channel && ins._reactInternalFiber.return) {
|
||||
var div = BDFDB.ReactUtils.findDOMNode(ins);
|
||||
div = div && BDFDB.DOMUtils.containsClass(div.parentElement, BDFDB.disCN.categorycontainerdefault, BDFDB.disCN.channelcontainerdefault, false) ? div.parentElement : div;
|
||||
found.push(Object.assign(new ins.props.channel.constructor(ins.props.channel), {div, instance:ins}));
|
||||
|
@ -2122,7 +2122,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.DMUtils.getAll = function () {
|
||||
var found = [];
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:"DirectMessage", all:true, noCopies:true, unlimited:true})) {
|
||||
for (let ins of BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:"DirectMessage", all:true, unlimited:true})) {
|
||||
if (ins.props && ins.props.channel) found.push(Object.assign(new ins.props.channel.constructor(ins.props.channel), {div:BDFDB.ReactUtils.findDOMNode(ins), instance:ins}));
|
||||
}
|
||||
return found;
|
||||
|
@ -2728,24 +2728,24 @@ var BDFDB = {
|
|||
BDFDB.DOMUtils = {};
|
||||
BDFDB.DOMUtils.addClass = function (eles, ...classes) {
|
||||
if (!eles || !classes) return;
|
||||
for (let ele of [eles].flat().filter(n => n)) {
|
||||
for (let ele of [eles].flat(10).filter(n => n)) {
|
||||
if (Node.prototype.isPrototypeOf(ele)) add(ele);
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) for (let e of ele) add(e);
|
||||
else if (typeof ele == "string") for (let e of ele.split(",")) if (e && (e = e.trim())) for (let n of document.querySelectorAll(e)) add(n);
|
||||
}
|
||||
function add(node) {
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat().filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.add(c);
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat(10).filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.add(c);
|
||||
}
|
||||
};
|
||||
BDFDB.DOMUtils.removeClass = function (eles, ...classes) {
|
||||
if (!eles || !classes) return;
|
||||
for (let ele of [eles].flat().filter(n => n)) {
|
||||
for (let ele of [eles].flat(10).filter(n => n)) {
|
||||
if (Node.prototype.isPrototypeOf(ele)) remove(ele);
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) for (let e of ele) remove(e);
|
||||
else if (typeof ele == "string") for (let e of ele.split(",")) if (e && (e = e.trim())) for (let n of document.querySelectorAll(e)) remove(n);
|
||||
}
|
||||
function remove(node) {
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat().filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.remove(c);
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat(10).filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.remove(c);
|
||||
}
|
||||
};
|
||||
BDFDB.DOMUtils.toggleClass = function (eles, ...classes) {
|
||||
|
@ -2756,14 +2756,14 @@ var BDFDB = {
|
|||
force = undefined;
|
||||
}
|
||||
if (!classes.length) return;
|
||||
for (let ele of [eles].flat().filter(n => n)) {
|
||||
for (let ele of [eles].flat(10).filter(n => n)) {
|
||||
if (!ele) {}
|
||||
else if (Node.prototype.isPrototypeOf(ele)) toggle(ele);
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) for (let e of ele) toggle(e);
|
||||
else if (typeof ele == "string") for (let e of ele.split(",")) if (e && (e = e.trim())) for (let n of document.querySelectorAll(e)) toggle(n);
|
||||
}
|
||||
function toggle(node) {
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat().filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.toggle(c, force);
|
||||
if (node && node.classList) for (let cla of classes) for (let cl of [cla].flat(10).filter(n => n)) if (typeof cl == "string") for (let c of cl.split(" ")) if (c) node.classList.toggle(c, force);
|
||||
}
|
||||
};
|
||||
BDFDB.DOMUtils.containsClass = function (eles, ...classes) {
|
||||
|
@ -2792,7 +2792,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.DOMUtils.replaceClass = function (eles, oldclass, newclass) {
|
||||
if (!eles || typeof oldclass != "string" || typeof newclass != "string") return;
|
||||
for (let ele of [eles].flat().filter(n => n)) {
|
||||
for (let ele of [eles].flat(10).filter(n => n)) {
|
||||
if (Node.prototype.isPrototypeOf(ele)) replace(ele);
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) for (let e of ele) replace(e);
|
||||
else if (typeof ele == "string") for (let e of ele.split(",")) if (e && (e = e.trim())) for (let n of document.querySelectorAll(e)) replace(n);
|
||||
|
@ -2802,10 +2802,10 @@ var BDFDB = {
|
|||
}
|
||||
};
|
||||
BDFDB.DOMUtils.formatClassName = function (...classes) {
|
||||
return BDFDB.ArrayUtils.removeCopies(classes.flat().filter(n => n).join(" ").split(" ")).join(" ").trim();
|
||||
return BDFDB.ArrayUtils.removeCopies(classes.flat(10).filter(n => n).join(" ").split(" ")).join(" ").trim();
|
||||
};
|
||||
BDFDB.DOMUtils.removeClassFromDOM = function (...classes) {
|
||||
for (let c of classes.flat().filter(n => n)) if (typeof c == "string") for (let a of c.split(",")) if (a && (a = a.replace(/\.|\s/g, ""))) BDFDB.DOMUtils.removeClass(document.querySelectorAll("." + a), a);
|
||||
for (let c of classes.flat(10).filter(n => n)) if (typeof c == "string") for (let a of c.split(",")) if (a && (a = a.replace(/\.|\s/g, ""))) BDFDB.DOMUtils.removeClass(document.querySelectorAll("." + a), a);
|
||||
};
|
||||
BDFDB.DOMUtils.show = function (...eles) {
|
||||
BDFDB.DOMUtils.toggle(...eles, true);
|
||||
|
@ -2821,7 +2821,7 @@ var BDFDB = {
|
|||
force = undefined;
|
||||
}
|
||||
if (!eles.length) return;
|
||||
for (let ele of eles.flat().filter(n => n)) {
|
||||
for (let ele of eles.flat(10).filter(n => n)) {
|
||||
if (Node.prototype.isPrototypeOf(ele)) toggle(ele);
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) for (let node of ele) toggle(node);
|
||||
else if (typeof ele == "string") for (let c of ele.split(",")) if (c && (c = c.trim())) for (let node of document.querySelectorAll(c)) toggle(node);
|
||||
|
@ -2837,7 +2837,7 @@ var BDFDB = {
|
|||
if (Node.prototype.isPrototypeOf(node) && node.nodeType != Node.TEXT_NODE) return getComputedStyle(node, null).getPropertyValue("display") == "none";
|
||||
};
|
||||
BDFDB.DOMUtils.remove = function (...eles) {
|
||||
for (let ele of eles.flat().filter(n => n)) {
|
||||
for (let ele of eles.flat(10).filter(n => n)) {
|
||||
if (Node.prototype.isPrototypeOf(ele)) ele.remove();
|
||||
else if (NodeList.prototype.isPrototypeOf(ele)) {
|
||||
let nodes = Array.from(ele);
|
||||
|
@ -3469,7 +3469,7 @@ var BDFDB = {
|
|||
}
|
||||
if (config.children) {
|
||||
let selectedtab, tabbaritems = [];
|
||||
for (let child of [config.children].flat().filter(n => n)) if (LibraryModules.React.isValidElement(child)) {
|
||||
for (let child of [config.children].flat(10).filter(n => n)) if (LibraryModules.React.isValidElement(child)) {
|
||||
if (child.type == LibraryComponents.ModalComponents.ModalTabContent) {
|
||||
if (!tabbaritems.length) child.props.open = true;
|
||||
else delete child.props.open;
|
||||
|
@ -3764,7 +3764,7 @@ var BDFDB = {
|
|||
else return setTimeout(() => {BDFDB.TimeUtils.suppress(callback, "Timeout")();}, delay);
|
||||
};
|
||||
BDFDB.TimeUtils.clear = function (...timeobjects) {
|
||||
for (let t of timeobjects.flat().filter(n => n)) {
|
||||
for (let t of timeobjects.flat(10).filter(n => n)) {
|
||||
if (typeof t == "number") {
|
||||
clearInterval(t);
|
||||
clearTimeout(t);
|
||||
|
@ -6648,7 +6648,7 @@ var BDFDB = {
|
|||
children: this.props.title
|
||||
})
|
||||
}) : null
|
||||
].concat([this.props.titlechildren].flat()).filter(n => n)
|
||||
].concat([this.props.titlechildren].flat(10)).filter(n => n)
|
||||
}),
|
||||
].concat(this.props.children)
|
||||
});
|
||||
|
@ -6772,7 +6772,7 @@ var BDFDB = {
|
|||
align: LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(NativeSubComponents.KeybindRecorder, BDFDB.ObjectUtils.exclude(Object.assign({}, this.props, {
|
||||
defaultValue: [this.props.defaultValue].flat().filter(n => n).map(keycode => [BDFDB.DiscordConstants.KeyboardDeviceTypes.KEYBOARD_KEY, keycode, BDFDB.DiscordConstants.KeyboardEnvs.BROWSER]),
|
||||
defaultValue: [this.props.defaultValue].flat(10).filter(n => n).map(keycode => [BDFDB.DiscordConstants.KeyboardDeviceTypes.KEYBOARD_KEY, keycode, BDFDB.DiscordConstants.KeyboardEnvs.BROWSER]),
|
||||
onChange: this.handleChange.bind(this)
|
||||
}), "reset", "onReset")),
|
||||
this.props.reset || this.props.onReset ? BDFDB.ReactUtils.createElement(LibraryComponents.Clickable, {
|
||||
|
@ -7166,7 +7166,7 @@ var BDFDB = {
|
|||
wrap: true,
|
||||
children: BDFDB.ReactUtils.createElement(childcomponent, BDFDB.ObjectUtils.exclude(Object.assign(BDFDB.ObjectUtils.exclude(this.props, "className", "id", "type"), this.props.childProps, {onChange: this.handleChange.bind(this)}), "grow", "stretch", "basis", "dividerbottom", "dividertop", "label", "labelchildren", "mini", "note", "childProps"))
|
||||
})
|
||||
].flat().filter(n => n)
|
||||
].flat(10).filter(n => n)
|
||||
}),
|
||||
typeof this.props.note == "string" ? BDFDB.ReactUtils.createElement(LibraryComponents.Flex.Child, {
|
||||
className: BDFDB.disCN.note,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -334,7 +334,7 @@ class PersonalPins {
|
|||
BDFDB.ArrayUtils.keySort(messages, sort);
|
||||
messages.reverse();
|
||||
return Object.keys(messages).length ?
|
||||
messages.map(messagedata => this.renderMessage(buttoninstance, messagedata.note, messagedata.message, messagedata.channel, filter)).flat().filter(n => n) :
|
||||
messages.map(messagedata => this.renderMessage(buttoninstance, messagedata.note, messagedata.message, messagedata.channel, filter)).flat(10).filter(n => n) :
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessagesPopoutComponents.EmptyStateCenter, {
|
||||
msg: BDFDB.LanguageUtils.LanguageStrings.AUTOCOMPLETE_NO_RESULTS_HEADER,
|
||||
image: lighttheme ? "/assets/03c7541028afafafd1a9f6a81cb7f149.svg" : "/assets/6793e022dc1b065b21f12d6df02f91bd.svg"
|
||||
|
|
|
@ -365,7 +365,7 @@ class PinDMs {
|
|||
})
|
||||
})
|
||||
})
|
||||
].concat(e.returnvalue.props.children).flat();
|
||||
].concat(e.returnvalue.props.children).flat(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class ServerHider {
|
||||
getName () {return "ServerHider";}
|
||||
|
||||
getVersion () {return "6.0.9";}
|
||||
getVersion () {return "6.1.0";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,63 +11,17 @@ class ServerHider {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
|
||||
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"],["Folder Support","You can now also hide folders with the plugin"]]
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
after: {
|
||||
"Guild":["componentDidMount","componentDidUpdate"]
|
||||
Guilds: "render"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
initConstructor () {
|
||||
this.serverHiderModalMarkup =
|
||||
`<span class="${this.name}-modal BDFDB-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
<div class="${BDFDB.disCN.modal}">
|
||||
<div class="${BDFDB.disCN.modalinner}">
|
||||
<div class="${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizemedium}">
|
||||
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
|
||||
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
|
||||
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.defaultcolor + BDFDB.disCN.h4defaultmargin}">REPLACE_modal_header_text</h4>
|
||||
<div class="${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}"></div>
|
||||
</div>
|
||||
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">
|
||||
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<path d="M0 0h12v12H0"></path>
|
||||
<path class="fill" fill="currentColor" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.scrollerthemeghosthairline}">
|
||||
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner} entries"></div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontalreverse + BDFDB.disCNS.horizontalreverse2 + BDFDB.disCNS.directionrowreverse + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN.modalfooter}">
|
||||
<button type="button" class="btn-ok ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}"></div>
|
||||
</button>
|
||||
<button type="button" class="btn-all ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlooklink + BDFDB.disCNS.buttoncolortransparent + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
this.serverEntryMarkup =
|
||||
`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">
|
||||
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} serverhiderName" style="flex: 1 1 auto; white-space: nowrap;"></h3>
|
||||
<div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;">
|
||||
<input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} serverhiderCheckbox">
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
clearNotifications: {value:false, description:"Automatically clear any kind of notification of all hidden servers."},
|
||||
|
@ -78,24 +32,31 @@ class ServerHider {
|
|||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
||||
for (let key in settings) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
||||
}
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Reset all Servers.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {
|
||||
BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset all servers?", () => {
|
||||
BDFDB.DataUtils.remove(this, "servers");
|
||||
BDFDB.GuildUtils.getAll().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.DOMUtils.hide(info.div);});
|
||||
});
|
||||
});
|
||||
return settingspanel;
|
||||
let settingsitems = [];
|
||||
|
||||
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key]
|
||||
}));
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Button",
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
||||
label: "Unhide all Servers/Folders",
|
||||
onClick: _ => {
|
||||
BDFDB.ModalUtils.confirm(this, "Are you sure you want to unhide all servers and folders?", () => {
|
||||
BDFDB.DataUtils.save([], this, "hidden");
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
});
|
||||
},
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.RESET
|
||||
}));
|
||||
|
||||
return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
|
||||
}
|
||||
|
||||
//legacy
|
||||
|
@ -126,6 +87,13 @@ class ServerHider {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.PluginUtils.init(this);
|
||||
|
||||
// REMOVE 22.11.2019
|
||||
let olddata = BDFDB.DataUtils.load(this, "hiddenservers", "hiddenservers");
|
||||
if (olddata) {
|
||||
BDFDB.DataUtils.save(olddata, this, "hidden", "servers");
|
||||
BDFDB.DataUtils.remove(this, "hiddenservers");
|
||||
}
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
@ -136,11 +104,7 @@ class ServerHider {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
BDFDB.GuildUtils.getAll().forEach(info => {
|
||||
if (info.div.ServerHiderChangeObserver && typeof info.div.ServerHiderChangeObserver.disconnect == "function") info.div.ServerHiderChangeObserver.disconnect();
|
||||
if (!info.div.getAttribute("folder")) BDFDB.DOMUtils.show(info.div);
|
||||
delete info.div.ServerHiderChanged;
|
||||
});
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
|
@ -149,16 +113,10 @@ class ServerHider {
|
|||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
|
||||
this.serverEntryMarkup = this.serverEntryMarkup.replace("REPLACE_btn_visible_text", this.labels.btn_visible_text);
|
||||
}
|
||||
|
||||
onGuildContextMenu (instance, menu, returnvalue) {
|
||||
if (document.querySelector(".BDFDB-modal")) return;
|
||||
if (instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
||||
onGuildContextMenu (e) {
|
||||
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
|
||||
if (e.instance.props.target && e.instance.props.type.startsWith("GUILD_ICON_")) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
||||
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
|
||||
|
@ -168,19 +126,19 @@ class ServerHider {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.submenu_openhidemenu_text,
|
||||
action: _ => {
|
||||
BDFDB.ContextMenuUtils.close(menu);
|
||||
this.showServerModal();
|
||||
BDFDB.ContextMenuUtils.close(e.instance);
|
||||
this.showHideModal();
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.submenu_hideserver_text,
|
||||
disabled: !(instance.props.guild && !instance.props.target.getAttribute("folder")),
|
||||
!e.instance.props.guild && !e.instance.props.folderId ? null : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: e.instance.props.guild ? this.labels.submenu_hideserver_text : this.labels.submenu_hidefolder_text,
|
||||
action: _ => {
|
||||
BDFDB.ContextMenuUtils.close(menu);
|
||||
this.toggleServer(instance.props.guild, instance.props.target, false);
|
||||
BDFDB.ContextMenuUtils.close(e.instance);
|
||||
if (e.instance.props.guild) this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "servers") || [], e.instance.props.guild.id, "servers");
|
||||
else this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "folders") || [], e.instance.props.folderId, "folders");
|
||||
}
|
||||
})
|
||||
]
|
||||
].filter(n => n)
|
||||
})]
|
||||
})
|
||||
]
|
||||
|
@ -190,70 +148,134 @@ class ServerHider {
|
|||
}
|
||||
}
|
||||
|
||||
processGuild (instance, wrapper, returnvalue, methodnames) {
|
||||
if (instance.props.guild) {
|
||||
let hiddenservers = BDFDB.DataUtils.load(this, "hiddenservers", "hiddenservers") || [];
|
||||
if (methodnames.includes("componentDidMount")) this.toggleServer(instance.props.guild, wrapper, !hiddenservers.includes(instance.props.guild.id));
|
||||
if (methodnames.includes("componentDidUpdate") && hiddenservers.includes(instance.props.guild.id) && instance.props.unread) this.unreadServer(instance.props.guild.id);
|
||||
}
|
||||
}
|
||||
|
||||
showServerModal () {
|
||||
let serverHiderModal = BDFDB.DOMUtils.create(this.serverHiderModalMarkup);
|
||||
let container = serverHiderModal.querySelector(".entries");
|
||||
if (!container) return;
|
||||
|
||||
BDFDB.ListenerUtils.addToChildren(serverHiderModal, "click", ".btn-all", () => {
|
||||
let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox");
|
||||
firstcheckbox.click();
|
||||
serverHiderModal.querySelectorAll(".serverhiderCheckbox").forEach(checkbox => {
|
||||
if (checkbox != firstcheckbox && checkbox.checked != firstcheckbox.checked) checkbox.click();
|
||||
});
|
||||
});
|
||||
|
||||
for (let info of BDFDB.GuildUtils.getAll()) {
|
||||
if (!info.div.getAttribute("folder")) {
|
||||
if (container.firstElementChild) container.appendChild(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN.divider}"></div>`));
|
||||
let entry = BDFDB.DOMUtils.create(this.serverEntryMarkup);
|
||||
container.appendChild(entry);
|
||||
let name = entry.querySelector(".serverhiderName");
|
||||
name.innerText = info.name || "";
|
||||
name.parentElement.insertBefore(BDFDB.GuildUtils.createCopy(info, {click: () => {BDFDB.DOMUtils.remove(serverHiderModal);}, menu: true, size: 48}), name);
|
||||
let hidecheckbox = entry.querySelector(".serverhiderCheckbox");
|
||||
hidecheckbox.checked = !BDFDB.DOMUtils.isHidden(info.div);
|
||||
hidecheckbox.addEventListener("click", e => {
|
||||
this.toggleServer(info, info.div, e.currentTarget.checked);
|
||||
});
|
||||
processGuilds (e) {
|
||||
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
|
||||
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
|
||||
if (hiddenGuildIds.length || hiddenFolderIds.length) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["DragSource(ForwardRef(FluxContainer(GuildFolder)))", "DragSource(ForwardRef(FluxContainer(Guild)))"]});
|
||||
if (index > -1) for (let i in children) {
|
||||
let child = children[i];
|
||||
if (child.props.folderId) {
|
||||
if (hiddenFolderIds.includes(child.props.folderId)) children[i] = null;
|
||||
else {
|
||||
let guildIds = [].concat(child.props.guildIds.filter(guildId => !hiddenGuildIds.includes(guildId)));
|
||||
if (guildIds.length) child.props.guildIds = guildIds;
|
||||
else children[i] = null;
|
||||
}
|
||||
}
|
||||
else if (child.props.guildId && hiddenGuildIds.includes(child.props.guildId)) children[i] = null;
|
||||
}
|
||||
}
|
||||
BDFDB.appendModal(serverHiderModal);
|
||||
}
|
||||
|
||||
toggleServer (info, target, visible) {
|
||||
if (!info || !target) return;
|
||||
let guilddiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, target);
|
||||
if (!guilddiv || guilddiv.getAttribute("folder")) return;
|
||||
BDFDB.DOMUtils.toggle(guilddiv, visible);
|
||||
let hiddenservers = BDFDB.DataUtils.load(this, "hiddenservers", "hiddenservers") || [];
|
||||
BDFDB.ArrayUtils.remove(hiddenservers, info.id);
|
||||
if (!visible) {
|
||||
if (BDFDB.ReactUtils.getValue(guilddiv, "return.stateNode.props").unread) this.unreadServer(info.id);
|
||||
hiddenservers.push(info.id);
|
||||
}
|
||||
BDFDB.DataUtils.save(hiddenservers, this, "hiddenservers", "hiddenservers");
|
||||
showHideModal () {
|
||||
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
|
||||
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
|
||||
let guilds = BDFDB.LibraryModules.FolderStore.getFlattenedGuilds();
|
||||
let folders = BDFDB.LibraryModules.FolderStore.guildFolders.filter(n => n.folderId);
|
||||
let foldersAdded = [];
|
||||
|
||||
BDFDB.ModalUtils.open(this, {
|
||||
size: "MEDIUM",
|
||||
header: this.labels.modal_header_text,
|
||||
subheader: "",
|
||||
contentClassName: BDFDB.disCN.listscroller,
|
||||
children: guilds.map((guild, i) => {
|
||||
let folder = folders.find(folder => folder.guildIds.includes(guild.id) && !foldersAdded.includes(folder.folderId));
|
||||
if (folder) foldersAdded.push(folder.folderId);
|
||||
return [
|
||||
folder ? [
|
||||
folders.indexOf(folder) == 0 ? null : [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom4
|
||||
})
|
||||
],
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
|
||||
prefix: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.listavatar,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.BlobMask, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Clickable, {
|
||||
className: BDFDB.disCN.guildfolder,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfoldericonwrapper,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfoldericonwrapperexpanded,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.FOLDER,
|
||||
style: {color: BDFDB.ColorUtils.convert(folder.folderColor, "RGB")}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}),
|
||||
label: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
children: folder.folderName || `${BDFDB.LanguageUtils.LanguageStrings.SERVER_FOLDER_PLACEHOLDER} #${folders.indexOf(folder) + 1}`
|
||||
}),
|
||||
suffix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
||||
value: !hiddenFolderIds.includes(folder.folderId),
|
||||
onChange: value => {this.toggleItem(hiddenFolderIds, folder.folderId, "folders", value);}
|
||||
})
|
||||
})
|
||||
] : null,
|
||||
i == 0 && !folder ? null : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
|
||||
prefix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Guild, {
|
||||
className: BDFDB.disCN.listavatar,
|
||||
guild: guild,
|
||||
menu: false,
|
||||
tooltip: false
|
||||
}),
|
||||
label: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
children: guild.name
|
||||
}),
|
||||
suffix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
||||
value: !hiddenGuildIds.includes(guild.id),
|
||||
onChange: value => {this.toggleItem(hiddenGuildIds, guild.id, "servers", value);}
|
||||
})
|
||||
})
|
||||
];
|
||||
}).flat(10).filter(n => n),
|
||||
buttons: [{
|
||||
contents: BDFDB.LanguageUtils.LanguageStrings.OKAY,
|
||||
color: "BRAND",
|
||||
close: true
|
||||
}, {
|
||||
contents: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL,
|
||||
color: "TRANSPARENT",
|
||||
look: "LINK",
|
||||
click: (modal, instance) => {
|
||||
let enabled = hiddenGuildIds.includes(guilds[0].id);
|
||||
hiddenGuildIds = [].concat(enabled ? [] : guilds.map(n => n.id));
|
||||
BDFDB.DataUtils.save(hiddenGuildIds, this, "hidden", "servers");
|
||||
hiddenFolderIds = [].concat(enabled ? [] : folders.map(n => n.folderId));
|
||||
BDFDB.DataUtils.save(hiddenFolderIds, this, "hidden", "folders");
|
||||
let switchInstances = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_Switch", all:true, unlimited:true});
|
||||
for (let switchIns of switchInstances) switchIns.props.value = enabled;
|
||||
BDFDB.ReactUtils.forceUpdate(switchInstances);
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
toggleItem (array, id, type, force) {
|
||||
if (!id) return;
|
||||
if (force || (force === undefined && array.includes(id))) BDFDB.ArrayUtils.remove(array, id, true);
|
||||
else array.push(id);
|
||||
BDFDB.DataUtils.save(array, this, "hidden", type);
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
unreadServer (id) {
|
||||
if (BDFDB.DataUtils.get(this, "settings", "clearNotifications") && !this.isInFolder(id)) BDFDB.GuildUtils.markAsRead(id);
|
||||
}
|
||||
|
||||
isInFolder (id) {
|
||||
if (!BDFDB.BDUtils.isPluginEnabled("ServerFolders")) return false;
|
||||
let folders = BDFDB.DataUtils.load("ServerFolders", "folders");
|
||||
for (let folderid in folders) if ((folders[folderid].servers || []).includes(id)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
@ -261,20 +283,23 @@ class ServerHider {
|
|||
modal_header_text: "Upravljanje popisom poslužitelja",
|
||||
context_serverhider_text: "Vidljivost poslužitelj",
|
||||
submenu_hideserver_text: "Sakrij poslužitelj",
|
||||
submenu_hidefolder_text: "Sakrij mapu",
|
||||
submenu_openhidemenu_text: "Upravljanje popisom poslužitelja"
|
||||
};
|
||||
case "da": //danish
|
||||
return {
|
||||
modal_header_text: "Styring af Serverliste",
|
||||
modal_header_text: "Styring af serverliste",
|
||||
context_serverhider_text: "Server synlighed",
|
||||
submenu_hideserver_text: "Skjul Server",
|
||||
submenu_openhidemenu_text: "Styre Serverliste"
|
||||
submenu_hideserver_text: "Skjul server",
|
||||
submenu_hidefolder_text: "Skjul mappe",
|
||||
submenu_openhidemenu_text: "Styre serverliste"
|
||||
};
|
||||
case "de": //german
|
||||
return {
|
||||
modal_header_text: "Verwaltung der Serverliste",
|
||||
context_serverhider_text: "Serversichtbarkeit",
|
||||
submenu_hideserver_text: "Server verstecken",
|
||||
submenu_hidefolder_text: "Ordner verstecken",
|
||||
submenu_openhidemenu_text: "Serverliste verwalten"
|
||||
};
|
||||
case "es": //spanish
|
||||
|
@ -282,6 +307,7 @@ class ServerHider {
|
|||
modal_header_text: "Administración de lista de servidores",
|
||||
context_serverhider_text: "Visibilidad del servidor",
|
||||
submenu_hideserver_text: "Ocultar servidor",
|
||||
submenu_hidefolder_text: "Ocultar carpeta",
|
||||
submenu_openhidemenu_text: "Administrar lista de servidores"
|
||||
};
|
||||
case "fr": //french
|
||||
|
@ -289,6 +315,7 @@ class ServerHider {
|
|||
modal_header_text: "Gestion de la liste des serveurs",
|
||||
context_serverhider_text: "Visibilité du serveur",
|
||||
submenu_hideserver_text: "Cacher le serveur",
|
||||
submenu_hidefolder_text: "Cacher le dossier",
|
||||
submenu_openhidemenu_text: "Gérer la liste des serveurs"
|
||||
};
|
||||
case "it": //italian
|
||||
|
@ -296,6 +323,7 @@ class ServerHider {
|
|||
modal_header_text: "Gestione dell'elenco dei server",
|
||||
context_serverhider_text: "Visibilità del server",
|
||||
submenu_hideserver_text: "Nascondi il server",
|
||||
submenu_hidefolder_text: "Nascondi la cartella",
|
||||
submenu_openhidemenu_text: "Gestione elenco dei server"
|
||||
};
|
||||
case "nl": //dutch
|
||||
|
@ -303,6 +331,7 @@ class ServerHider {
|
|||
modal_header_text: "Beheer van de Serverlijst",
|
||||
context_serverhider_text: "Server zichtbaarheid",
|
||||
submenu_hideserver_text: "Verberg server",
|
||||
submenu_hidefolder_text: "Verberg map",
|
||||
submenu_openhidemenu_text: "Beheer serverlijst"
|
||||
};
|
||||
case "no": //norwegian
|
||||
|
@ -310,6 +339,7 @@ class ServerHider {
|
|||
modal_header_text: "Administrasjon av serverlisten",
|
||||
context_serverhider_text: "Server synlighet",
|
||||
submenu_hideserver_text: "Skjul server",
|
||||
submenu_hidefolder_text: "Skjul mappe",
|
||||
submenu_openhidemenu_text: "Administrer serverliste"
|
||||
};
|
||||
case "pl": //polish
|
||||
|
@ -317,6 +347,7 @@ class ServerHider {
|
|||
modal_header_text: "Zarządzanie listą serwerów",
|
||||
context_serverhider_text: "Widoczność serwera",
|
||||
submenu_hideserver_text: "Ukryj serwer",
|
||||
submenu_hidefolder_text: "Ukryj folder",
|
||||
submenu_openhidemenu_text: "Zarządzaj listą serwerów"
|
||||
};
|
||||
case "pt-BR": //portuguese (brazil)
|
||||
|
@ -324,6 +355,7 @@ class ServerHider {
|
|||
modal_header_text: "Gerenciamento da lista de servidores",
|
||||
context_serverhider_text: "Visibilidade do servidor",
|
||||
submenu_hideserver_text: "Ocultar servidor",
|
||||
submenu_hidefolder_text: "Ocultar pasta",
|
||||
submenu_openhidemenu_text: "Gerenciar lista de servidores"
|
||||
};
|
||||
case "fi": //finnish
|
||||
|
@ -331,6 +363,7 @@ class ServerHider {
|
|||
modal_header_text: "Palvelinluettelon hallinta",
|
||||
context_serverhider_text: "Palvelimen näkyvyys",
|
||||
submenu_hideserver_text: "Piilota palvelin",
|
||||
submenu_hidefolder_text: "Piilota kansio",
|
||||
submenu_openhidemenu_text: "Hallinnoi palvelinluetteloa"
|
||||
};
|
||||
case "sv": //swedish
|
||||
|
@ -338,6 +371,7 @@ class ServerHider {
|
|||
modal_header_text: "Hantering av serverlistan",
|
||||
context_serverhider_text: "Server sikt",
|
||||
submenu_hideserver_text: "Dölj server",
|
||||
submenu_hidefolder_text: "Dölj mapp",
|
||||
submenu_openhidemenu_text: "Hantera serverlistan"
|
||||
};
|
||||
case "tr": //turkish
|
||||
|
@ -345,6 +379,7 @@ class ServerHider {
|
|||
modal_header_text: "Sunucu Listesinin Yönetimi",
|
||||
context_serverhider_text: "Sunucu görünürlüğü",
|
||||
submenu_hideserver_text: "Sunucuyu Gizle",
|
||||
submenu_hidefolder_text: "Klasörü Gizle",
|
||||
submenu_openhidemenu_text: "Sunucu Listesini Yönet"
|
||||
};
|
||||
case "cs": //czech
|
||||
|
@ -352,6 +387,7 @@ class ServerHider {
|
|||
modal_header_text: "Správa seznamu serverů",
|
||||
context_serverhider_text: "Viditelnost serveru",
|
||||
submenu_hideserver_text: "Skrýt server",
|
||||
submenu_hidefolder_text: "Skrýt složky",
|
||||
submenu_openhidemenu_text: "Správa seznamu serverů"
|
||||
};
|
||||
case "bg": //bulgarian
|
||||
|
@ -359,6 +395,7 @@ class ServerHider {
|
|||
modal_header_text: "Управление на списъка със сървъри",
|
||||
context_serverhider_text: "Видимост на сървъра",
|
||||
submenu_hideserver_text: "Скриване на сървър",
|
||||
submenu_hidefolder_text: "Скриване на папка",
|
||||
submenu_openhidemenu_text: "Управление на списъка със сървъри"
|
||||
};
|
||||
case "ru": //russian
|
||||
|
@ -366,6 +403,7 @@ class ServerHider {
|
|||
modal_header_text: "Управление списком серверов",
|
||||
context_serverhider_text: "Видимость сервера",
|
||||
submenu_hideserver_text: "Скрыть сервер",
|
||||
submenu_hidefolder_text: "Скрыть папки",
|
||||
submenu_openhidemenu_text: "Управление списком серверов"
|
||||
};
|
||||
case "uk": //ukrainian
|
||||
|
@ -373,6 +411,7 @@ class ServerHider {
|
|||
modal_header_text: "Управління списком серверів",
|
||||
context_serverhider_text: "Видимість сервера",
|
||||
submenu_hideserver_text: "Сховати сервер",
|
||||
submenu_hidefolder_text: "Сховати папки",
|
||||
submenu_openhidemenu_text: "Управління списком серверів"
|
||||
};
|
||||
case "ja": //japanese
|
||||
|
@ -380,6 +419,7 @@ class ServerHider {
|
|||
modal_header_text: "サーバリストの管理",
|
||||
context_serverhider_text: "サーバーの可視性",
|
||||
submenu_hideserver_text: "サーバーを隠す",
|
||||
submenu_hidefolder_text: "フォルダーを非表示",
|
||||
submenu_openhidemenu_text: "サーバーリストを管理する"
|
||||
};
|
||||
case "zh-TW": //chinese (traditional)
|
||||
|
@ -387,6 +427,7 @@ class ServerHider {
|
|||
modal_header_text: "管理服务器列表",
|
||||
context_serverhider_text: "服務器可見性",
|
||||
submenu_hideserver_text: "隐藏服务器",
|
||||
submenu_hidefolder_text: "隱藏資料夾",
|
||||
submenu_openhidemenu_text: "管理服务器列表"
|
||||
};
|
||||
case "ko": //korean
|
||||
|
@ -394,6 +435,7 @@ class ServerHider {
|
|||
modal_header_text: "서버 목록 관리",
|
||||
context_serverhider_text: "서버 가시성",
|
||||
submenu_hideserver_text: "서버 숨기기",
|
||||
submenu_hidefolder_text: "폴더 숨기기",
|
||||
submenu_openhidemenu_text: "서버 목록 관리"
|
||||
};
|
||||
default: //default: english
|
||||
|
@ -401,6 +443,7 @@ class ServerHider {
|
|||
modal_header_text: "Managing Serverlist",
|
||||
context_serverhider_text: "Server Visibility",
|
||||
submenu_hideserver_text: "Hide Server",
|
||||
submenu_hidefolder_text: "Hide Folder",
|
||||
submenu_openhidemenu_text: "Manage Serverlist"
|
||||
};
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ class ShowHiddenChannels {
|
|||
children: formlabel.text
|
||||
})
|
||||
})
|
||||
]).flat().filter(n => n)
|
||||
]).flat(10).filter(n => n)
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
|
||||
tab: this.labels.modal_allowed_text,
|
||||
|
|
Loading…
Reference in New Issue