From 7305675a31d48686a8cd64e71d2463c0ce8a7f8a Mon Sep 17 00:00:00 2001 From: Mirco Wittrien <23700969+mwittrien@users.noreply.github.com> Date: Thu, 7 Jul 2022 17:46:42 +0200 Subject: [PATCH] stuff --- Library/_res/0BDFDB.data.json | 5 ++ .../ShowHiddenChannels.plugin.js | 47 ++++++------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Library/_res/0BDFDB.data.json b/Library/_res/0BDFDB.data.json index 772c851258..bd49aa1a3d 100644 --- a/Library/_res/0BDFDB.data.json +++ b/Library/_res/0BDFDB.data.json @@ -190,6 +190,10 @@ "GroupDMUserContextMenu": "UserContextMenu" }, "ContextMenuSubItemsMap": { + "ChannelContextMenu": { + "keys": ["channel"], + "items": ["useChannelFavoriteSetNickname", "useChannelGoToOriginalGuildItem", "useChannelCloneItem", "useChannelCopyLinkItem", "useChannelEditItem", "useChannelMarkAsReadItem"] + }, "UserContextMenu": { "keys": ["user", "channel"], "items": ["useHideNoVideoParticipantsItem", "useHideSelfVideoItem", "usePreviewVideoItem", "useChangeIdentityItem", "useMoveToAudienceItem", "useAddFriendNicknameItem", "useAddNoteItem", "useBlockUserItem", "useUserRelationshipItems", "useUserManagementItems", "useMoveUserVoiceItems", "useCallUserItem", "useFocusVideoItem", "useInviteUserToGuildItems", "useMentionUserItem", "useMessageUserItem", "useUserProfileItem", "useUserRolesItems", "useUserVolumeItem", "useWatchStreamItem", "useCloseDMItem", "useMuteChannelItem"] @@ -220,6 +224,7 @@ "useMuteChannelItem": {"strings": ["DM", "MenuItem", "Messages.MUTE_CHANNEL"], "lazyLoaded": true}, "useUserManagementItems": {"strings": ["canManageUser", "MenuItem", "Messages.BAN_USER"], "lazyLoaded": true}, "useUserRelationshipItems": {"strings": ["ContextMenu", "isFriend", "addRelationship", "Messages.REMOVE_FRIEND"], "lazyLoaded": true}, + "useInviteItem": {"strings": ["CREATE_INSTANT_INVITE", "invite-people"]}, "Account": {"class": "accountinfo"}, "App": {"class": "app"}, "AppSkeleton": {"class": "app"}, diff --git a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js index 493fde63d5..63caf05255 100644 --- a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js +++ b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js @@ -2,7 +2,7 @@ * @name ShowHiddenChannels * @author DevilBro * @authorId 278543574059057154 - * @version 3.2.2 + * @version 3.2.3 * @description Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible) * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,7 +17,7 @@ module.exports = (_ => { "info": { "name": "ShowHiddenChannels", "author": "DevilBro", - "version": "3.2.2", + "version": "3.2.3", "description": "Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible)" } }; @@ -202,6 +202,7 @@ module.exports = (_ => { VoiceUsers: "render" }, after: { + useInviteItem: "default", ChannelItem: "default" } }; @@ -330,41 +331,17 @@ module.exports = (_ => { onChannelContextMenu (e) { if (e.instance.props.channel) { - if (e.instance.props.channel.id.endsWith("hidden") && e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ChannelMuteItem"}); - if (index > -1) children.splice(index, 1); - [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: this.labels.context_changeorder, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "change_order"), - children: Object.keys(sortOrders).filter(n => sortOrders[n].value != sortOrders.EXTRA.value).map(n => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels["context_changeorder_" + sortOrders[n].value], - id: BDFDB.ContextMenuUtils.createItemId(this.name, "change_order", sortOrders[n].value), - action: _ => { - this.settings.sortOrder.hidden = sortOrders[n].value; - BDFDB.DataUtils.save(this.settings.sortOrder, this, "sortOrder"); - this.forceUpdateAll(); - } - }) - })) - }) - })); - } let isHidden = this.isChannelHidden(e.instance.props.channel.id); - if (isHidden) { + if (e.subType == "useChannelMarkAsReadItem" && (isHidden || this.settings.general.showForNormal)) { let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "invite-people"}); if (index > -1) children.splice(index, 1); } - if (isHidden || this.settings.general.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: this.labels.context_channelaccess, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "permissions"), - action: _ => this.openAccessModal(e.instance.props.channel, !isHidden) - }) + if (e.subType == "useChannelMarkAsReadItem" && (isHidden || this.settings.general.showForNormal)) { + if (e.returnvalue.length) e.returnvalue.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSeparator, {})); + e.returnvalue.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: this.labels.context_channelaccess, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "permissions"), + action: _ => this.openAccessModal(e.instance.props.channel, !isHidden) })); } } @@ -393,6 +370,10 @@ module.exports = (_ => { this.onGuildContextMenu(e); } + processUseInviteItem (e) { + if (e.instance.props.channel && this.isChannelHidden(e.instance.props.channel.id)) return null; + } + processChannels (e) { if (!e.instance.props.guild || e.instance.props.guild.id.length < 16) return; let show = !blackList.includes(e.instance.props.guild.id), sortAtBottom = this.settings.sortOrder.hidden == sortOrders.BOTTOM.value;