stuff
This commit is contained in:
parent
11c9f839ac
commit
ef795740f8
|
@ -3547,7 +3547,11 @@
|
|||
disabled: props.disabled,
|
||||
render: menuItemProps => {
|
||||
if (!props.state) props.state = BDFDB.ObjectUtils.extract(props, "checked", "value");
|
||||
return BDFDB.ReactUtils.createElement(component, Object.assign(props, menuItemProps, {color: props.color}), true);
|
||||
return BDFDB.ReactUtils.createElement(InternalComponents.CustomMenuItemWrapper, {
|
||||
disabled: props.disabled,
|
||||
childProps: Object.assign({}, props, menuItemProps, {color: props.color}),
|
||||
children: component
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -7024,6 +7028,23 @@
|
|||
})) : item;
|
||||
}
|
||||
};
|
||||
InternalComponents.CustomMenuItemWrapper = reactInitialized && class BDFDB_CustomMenuItemWrapper extends LibraryModules.React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {hovered: false};
|
||||
}
|
||||
render() {
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
onMouseEnter: e => {
|
||||
this.setState({hovered: true});
|
||||
},
|
||||
onMouseLeave: e => {
|
||||
this.setState({hovered: false});
|
||||
},
|
||||
children: BDFDB.ReactUtils.createElement(this.props.children, Object.assign({}, this.props.childProps, {isFocused:this.state.hovered && !this.props.disabled}))
|
||||
});
|
||||
}
|
||||
};
|
||||
InternalComponents.ErrorBoundary = reactInitialized && class BDFDB_ErrorBoundary extends LibraryModules.React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -10779,7 +10800,7 @@
|
|||
};
|
||||
|
||||
const ContextMenuTypes = ["UserSettingsCog", "User", "Developer", "Slate", "GuildFolder", "GroupDM", "SystemMessage", "Message", "Native", "Guild", "Channel"];
|
||||
const QueuedComponents = BDFDB.ArrayUtils.removeCopies([].concat(ContextMenuTypes.map(n => n + "ContextMenu"), ["MessageOptionContextMenu", "MessageOptionToolbar"]));
|
||||
const QueuedComponents = BDFDB.ArrayUtils.removeCopies([].concat(ContextMenuTypes.map(n => n + "ContextMenu"), ["GuildHeaderContextMenu", "MessageOptionContextMenu", "MessageOptionToolbar"]));
|
||||
InternalBDFDB.addContextListeners = function (plugin) {
|
||||
plugin = plugin == BDFDB && InternalBDFDB || plugin;
|
||||
for (let type of QueuedComponents) if (typeof plugin[`on${type}`] === "function") {
|
||||
|
@ -10839,6 +10860,12 @@
|
|||
}}, {once: true});
|
||||
}});
|
||||
|
||||
BDFDB.ModuleUtils.patch(BDFDB, BDFDB.ReactUtils.getValue(BDFDB.ModuleUtils.findByString("guild-header-popout", false), "exports.default.prototype"), "render", {after: e => {
|
||||
BDFDB.ModuleUtils.patch(BDFDB, e.returnValue.type, "type", {after: e2 => {
|
||||
InternalBDFDB.executeExtraPatchedPatches("GuildHeaderContextMenu", {instance:{props:e2.methodArguments[0]}, returnvalue:e2.returnValue, methodname:"type"});
|
||||
}}, {noCache: true});
|
||||
}});
|
||||
|
||||
InternalBDFDB.onSettingsClosed = function () {
|
||||
if (InternalBDFDB.SettingsUpdated) {
|
||||
delete InternalBDFDB.SettingsUpdated;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,8 @@
|
|||
//META{"name":"ShowHiddenChannels","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js"}*//
|
||||
|
||||
var ShowHiddenChannels = (_ => {
|
||||
var blacklist = [], hiddenCategory;
|
||||
var settings = {};
|
||||
|
||||
var blacklist = [], hiddenCategory, overrideTypes = [];
|
||||
|
||||
const settingsMap = {
|
||||
GUILD_TEXT: "showText",
|
||||
GUILD_VOICE: "showVoice",
|
||||
|
@ -15,7 +14,8 @@ var ShowHiddenChannels = (_ => {
|
|||
GUILD_TEXT: "TEXT_CHANNEL",
|
||||
GUILD_VOICE: "VOICE_CHANNEL",
|
||||
GUILD_ANNOUNCEMENT: "NEWS_CHANNEL",
|
||||
GUILD_STORE: "STORE_CHANNEL"
|
||||
GUILD_STORE: "STORE_CHANNEL",
|
||||
GUILD_CATEGORY: "CATEGORY"
|
||||
};
|
||||
|
||||
const channelIcons = {
|
||||
|
@ -89,7 +89,7 @@ var ShowHiddenChannels = (_ => {
|
|||
return class ShowHiddenChannels {
|
||||
getName () {return "ShowHiddenChannels";}
|
||||
|
||||
getVersion () {return "2.7.8";}
|
||||
getVersion () {return "2.7.9";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -97,7 +97,8 @@ var ShowHiddenChannels = (_ => {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"improved":[["UserId: id...","Instead of just showing the user id when a user is not cached, the plugin now tries to fetch the user"]]
|
||||
"fixed":[["Access Modal","Shows roles/users again"]],
|
||||
"improved":[["Hide locked channels toggle","Added toggle option similar to hide muted channels to server contextmenu"]]
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
|
@ -112,6 +113,8 @@ var ShowHiddenChannels = (_ => {
|
|||
}
|
||||
|
||||
initConstructor () {
|
||||
overrideTypes = Object.keys(BDFDB.DiscordConstants.PermissionOverrideType);
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
sortNative: {value:false, description:"Sort hidden Channels in the native Order"},
|
||||
|
@ -248,7 +251,7 @@ var ShowHiddenChannels = (_ => {
|
|||
for (let channel_id in all) if (all[channel_id].guild_id == e.methodArguments[0] && !e.returnValue[channel_id] && (all[channel_id].type != BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY && all[channel_id].type != BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE)) e.returnValue[channel_id] = {id: channel_id, name: all[channel_id].name};
|
||||
}});
|
||||
|
||||
this.forceUpdateAll();
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
||||
}
|
||||
|
@ -257,7 +260,7 @@ var ShowHiddenChannels = (_ => {
|
|||
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
this.forceUpdateAll();
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
|
@ -281,9 +284,9 @@ var ShowHiddenChannels = (_ => {
|
|||
if (index > -1) children.splice(index, 1);
|
||||
}
|
||||
let isHidden = this.isChannelHidden(e.instance.props.channel.id);
|
||||
if (isHidden || settings.showForNormal) {
|
||||
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
|
||||
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
||||
if (isHidden || BDFDB.DataUtils.get(this, "settings", "showForNormal")) {
|
||||
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-channel-read", group: true});
|
||||
children.splice(index > -1 ? index + 1 : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
||||
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||
label: BDFDB.LanguageUtils.LanguageStrings.CHANNEL + " " + BDFDB.LanguageUtils.LanguageStrings.ACCESSIBILITY,
|
||||
id: BDFDB.ContextMenuUtils.createItemId(this.name, "permissions"),
|
||||
|
@ -296,6 +299,28 @@ var ShowHiddenChannels = (_ => {
|
|||
}
|
||||
}
|
||||
|
||||
onGuildContextMenu (e) {
|
||||
if (e.instance.props.guild) {
|
||||
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "hide-muted-channels"});
|
||||
if (index > -1) children.splice(index + 1, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuCheckboxItem, {
|
||||
label: this.labels.context_hidehidden_text,
|
||||
id: BDFDB.ContextMenuUtils.createItemId(this.name, "hide-locked-channels"),
|
||||
checked: blacklist.includes(e.instance.props.guild.id),
|
||||
action: value => {
|
||||
if (value) blacklist.push(e.instance.props.guild.id);
|
||||
else BDFDB.ArrayUtils.remove(blacklist, e.instance.props.guild.id, true);
|
||||
this.saveBlacklist(BDFDB.ArrayUtils.removeCopies(blacklist));
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this, "Channels");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
onGuildHeaderContextMenu (e) {
|
||||
this.onGuildContextMenu(e);
|
||||
}
|
||||
|
||||
processChannels (e) {
|
||||
if (!e.instance.props.guild || blacklist.includes(e.instance.props.guild.id)) return;
|
||||
let [hiddenChannels, amount] = this.getHiddenChannels(e.instance.props.guild);
|
||||
|
@ -311,7 +336,7 @@ var ShowHiddenChannels = (_ => {
|
|||
e.instance.props.categories._categories = e.instance.props.categories._categories.filter(n => n.channel.id != hiddenId);
|
||||
e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY] = e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY].filter(n => n.channel.id != hiddenId);
|
||||
|
||||
let index = -1;
|
||||
let settings = BDFDB.DataUtils.get(this, "settings"), index = -1;
|
||||
for (let catId in e.instance.props.categories) {
|
||||
if (catId != "_categories") e.instance.props.categories[catId] = e.instance.props.categories[catId].filter(n => !this.isChannelHidden(n.channel.id));
|
||||
for (let channelObj of e.instance.props.categories[catId]) if (channelObj.index > index) index = parseInt(channelObj.index);
|
||||
|
@ -405,6 +430,7 @@ var ShowHiddenChannels = (_ => {
|
|||
|
||||
getHiddenChannels (guild) {
|
||||
if (!guild) return [{}, 0];
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let all = BDFDB.LibraryModules.ChannelStore.getChannels(), hidden = {}, amount = 0;
|
||||
for (let type in BDFDB.DiscordConstants.ChannelTypes) hidden[BDFDB.DiscordConstants.ChannelTypes[type]] = [];
|
||||
for (let channel_id in all) {
|
||||
|
@ -439,19 +465,19 @@ var ShowHiddenChannels = (_ => {
|
|||
let lightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
||||
let allowedRoles = [], allowedUsers = [], deniedRoles = [], deniedUsers = [], everyoneDenied = false;
|
||||
for (let id in channel.permissionOverwrites) {
|
||||
if (channel.permissionOverwrites[id].type == "role" && (guild.roles[id] && guild.roles[id].name != "@everyone") && ((channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow || (channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].allow)) {
|
||||
if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.ROLE || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.ROLE) && (guild.roles[id] && guild.roles[id].name != "@everyone") && ((channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow || (channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].allow)) {
|
||||
allowedRoles.push(Object.assign({overwritten: myMember.roles.includes(id) && !allowed}, guild.roles[id]));
|
||||
}
|
||||
else if (channel.permissionOverwrites[id].type == "member" && ((channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow || (channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].allow)) {
|
||||
else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && ((channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow || (channel.permissionOverwrites[id].allow | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].allow)) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) allowedUsers.push(Object.assign({}, user, BDFDB.LibraryModules.MemberStore.getMember(guild.id, id) || {}));
|
||||
else allowedUsers.push({id: id, username: `UserId: ${id}`, fetchable: true});
|
||||
}
|
||||
if (channel.permissionOverwrites[id].type == "role" && ((channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny || (channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].deny)) {
|
||||
if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.ROLE || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.ROLE) && ((channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny || (channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].deny)) {
|
||||
deniedRoles.push(guild.roles[id]);
|
||||
if (guild.roles[id] && guild.roles[id].name == "@everyone") everyoneDenied = true;
|
||||
}
|
||||
else if (channel.permissionOverwrites[id].type == "member" && ((channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny || (channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].deny)) {
|
||||
else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && ((channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny || (channel.permissionOverwrites[id].deny | BDFDB.DiscordConstants.Permissions.CONNECT) == channel.permissionOverwrites[id].deny)) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) deniedUsers.push(Object.assign({}, user, BDFDB.LibraryModules.MemberStore.getMember(guild.id, id) || {}));
|
||||
else deniedUsers.push({id: id, username: `UserId: ${id}`, fetchable: true});
|
||||
|
@ -478,7 +504,7 @@ var ShowHiddenChannels = (_ => {
|
|||
text: channel.name
|
||||
}, {
|
||||
title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_CHANNEL_TOPIC,
|
||||
text: channel.topic || BDFDB.LanguageUtils.LanguageStrings.CHANNEL_TOPIC_EMPTY
|
||||
text: channel.topic || "---"
|
||||
}, {
|
||||
title: BDFDB.LanguageUtils.LanguageStrings.CHANNEL_TYPE,
|
||||
text: BDFDB.LanguageUtils.LanguageStrings[typeNameMap[BDFDB.DiscordConstants.ChannelTypes[channel.type]]]
|
||||
|
@ -519,117 +545,132 @@ var ShowHiddenChannels = (_ => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
forceUpdateAll() {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "hr": //croatian
|
||||
return {
|
||||
context_hidehidden_text: "Sakrij skrivene kanale",
|
||||
modal_allowed_text: "Dopušteno",
|
||||
modal_denied_text: "Odbijen"
|
||||
};
|
||||
case "da": //danish
|
||||
return {
|
||||
context_hidehidden_text: "Skjul låste kanaler",
|
||||
modal_allowed_text: "Odbijen",
|
||||
modal_denied_text: "Nægtet"
|
||||
};
|
||||
case "de": //german
|
||||
return {
|
||||
context_hidehidden_text: "Versteckte Kanäle ausblenden",
|
||||
modal_allowed_text: "Erlaubt",
|
||||
modal_denied_text: "Verweigert"
|
||||
};
|
||||
case "es": //spanish
|
||||
return {
|
||||
context_hidehidden_text: "Ocultar canales bloqueados",
|
||||
modal_allowed_text: "Permitido",
|
||||
modal_denied_text: "Negado"
|
||||
};
|
||||
case "fr": //french
|
||||
return {
|
||||
context_hidehidden_text: "Masquer les salons verrouillées",
|
||||
modal_allowed_text: "Permis",
|
||||
modal_denied_text: "Nié"
|
||||
};
|
||||
case "it": //italian
|
||||
return {
|
||||
context_hidehidden_text: "Nascondi canali bloccati",
|
||||
modal_allowed_text: "Permesso",
|
||||
modal_denied_text: "Negato"
|
||||
};
|
||||
case "nl": //dutch
|
||||
return {
|
||||
context_hidehidden_text: "Vergrendelde kanalen verbergen",
|
||||
modal_allowed_text: "Toegestaan",
|
||||
modal_denied_text: "Ontkend"
|
||||
};
|
||||
case "no": //norwegian
|
||||
return {
|
||||
context_hidehidden_text: "Skjul låste kanaler",
|
||||
modal_allowed_text: "Tillatt",
|
||||
modal_denied_text: "Benektet"
|
||||
};
|
||||
case "pl": //polish
|
||||
return {
|
||||
context_hidehidden_text: "Ukryj zablokowane kanały",
|
||||
modal_allowed_text: "Dozwolony",
|
||||
modal_denied_text: "Odmówiono"
|
||||
};
|
||||
case "pt-BR": //portuguese (brazil)
|
||||
return {
|
||||
context_hidehidden_text: "Ocultar canais bloqueados",
|
||||
modal_allowed_text: "Permitido",
|
||||
modal_denied_text: "Negado"
|
||||
};
|
||||
case "fi": //finnish
|
||||
return {
|
||||
context_hidehidden_text: "Piilota lukitut kanavat",
|
||||
modal_allowed_text: "Sallittu",
|
||||
modal_denied_text: "Evätty"
|
||||
};
|
||||
case "sv": //swedish
|
||||
return {
|
||||
context_hidehidden_text: "Dölj låsta kanaler",
|
||||
modal_allowed_text: "Tillåten",
|
||||
modal_denied_text: "Nekas"
|
||||
};
|
||||
case "tr": //turkish
|
||||
return {
|
||||
context_hidehidden_text: "Kilitli Kanalları Gizle",
|
||||
modal_allowed_text: "Izin",
|
||||
modal_denied_text: "Inkar"
|
||||
};
|
||||
case "cs": //czech
|
||||
return {
|
||||
context_hidehidden_text: "Skrýt uzamčené kanály",
|
||||
modal_allowed_text: "Povoleno",
|
||||
modal_denied_text: "Odepřeno"
|
||||
};
|
||||
case "bg": //bulgarian
|
||||
return {
|
||||
context_hidehidden_text: "Скриване на заключени канали",
|
||||
modal_allowed_text: "Позволен",
|
||||
modal_denied_text: "Отказан"
|
||||
};
|
||||
case "ru": //russian
|
||||
return {
|
||||
context_hidehidden_text: "Скрыть заблокированные каналы",
|
||||
modal_allowed_text: "Разрешается",
|
||||
modal_denied_text: "Отказано"
|
||||
};
|
||||
case "uk": //ukrainian
|
||||
return {
|
||||
context_hidehidden_text: "Сховати заблоковані канали",
|
||||
modal_allowed_text: "Дозволено",
|
||||
modal_denied_text: "Заперечували"
|
||||
};
|
||||
case "ja": //japanese
|
||||
return {
|
||||
context_hidehidden_text: "ロックされたチャンネルを隠す",
|
||||
modal_allowed_text: "許可された",
|
||||
modal_denied_text: "拒否されました"
|
||||
};
|
||||
case "zh-TW": //chinese (traditional)
|
||||
return {
|
||||
context_hidehidden_text: "隱藏鎖定的頻道",
|
||||
modal_allowed_text: "允許的",
|
||||
modal_denied_text: "被拒絕"
|
||||
};
|
||||
case "ko": //korean
|
||||
return {
|
||||
context_hidehidden_text: "잠긴 채널 숨기기",
|
||||
modal_allowed_text: "허용됨",
|
||||
modal_denied_text: "거부"
|
||||
};
|
||||
default: //default: english
|
||||
return {
|
||||
context_hidehidden_text: "Hide Locked Channels",
|
||||
modal_allowed_text: "Permitted",
|
||||
modal_denied_text: "Denied"
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue