aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-01-14 23:00:29 +0100
committerVendicated <vendicated@riseup.net>2023-01-14 23:01:19 +0100
commit7478e880a8920479f6a7026d90c3a1b93ddd8a70 (patch)
tree6517892348966ff75dff61fb37613c068dacb86f /src/plugins
parentbe7fa0cb3f7a30c604315d08f6bf3a4dc51c62a5 (diff)
downloadVencord-7478e880a8920479f6a7026d90c3a1b93ddd8a70.tar.gz
Vencord-7478e880a8920479f6a7026d90c3a1b93ddd8a70.tar.bz2
Vencord-7478e880a8920479f6a7026d90c3a1b93ddd8a70.zip
ShowHiddenChannels: Use Lock as ChannelIcon
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/showHiddenChannels.tsx40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/plugins/showHiddenChannels.tsx b/src/plugins/showHiddenChannels.tsx
index ea6fcc2..a97259a 100644
--- a/src/plugins/showHiddenChannels.tsx
+++ b/src/plugins/showHiddenChannels.tsx
@@ -18,23 +18,20 @@
import { Settings } from "@api/settings";
+import { Badge } from "@components/Badge";
import { Flex } from "@components/Flex";
import { Devs } from "@utils/constants";
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal";
import definePlugin, { OptionType } from "@utils/types";
-import { waitFor } from "@webpack";
-import { Button, ChannelStore, SnowflakeUtils, Text } from "@webpack/common";
+import { Button, ChannelStore, PermissionStore, SnowflakeUtils, Text } from "@webpack/common";
const CONNECT = 1048576n;
const VIEW_CHANNEL = 1024n;
-let can = (permission, channel) => true;
-waitFor(m => m.can && m.initialize, m => ({ can } = m));
-
export default definePlugin({
name: "ShowHiddenChannels",
description: "Show hidden channels",
- authors: [Devs.BigDuck, Devs.AverageReactEnjoyer, Devs.D3SOX],
+ authors: [Devs.BigDuck, Devs.AverageReactEnjoyer, Devs.D3SOX, Devs.Ven],
options: {
hideUnreads: {
description: "Hide unreads",
@@ -84,8 +81,17 @@ export default definePlugin({
match: /((.)\.getGuildId\(\))(&&\(!\(.\.isThread.{1,100}\.hasRelevantUnread\()/,
replace: "$1&&!$2._isHiddenChannel$3"
}
+ },
+ // Lock Icon
+ {
+ find: ".rulesChannelId))",
+ replacement: {
+ match: /(\.locked.{0,400})(switch\((\i)\.type\))/,
+ replace: "$1 if($3._isHiddenChannel)return $self.LockIcon;$2"
+ }
}
],
+
shouldShow(channel, category, isMuted) {
if (!this.isHiddenChannel(channel)) return false;
if (!category) return false;
@@ -93,6 +99,7 @@ export default definePlugin({
return !category.isCollapsed;
},
+
isHiddenChannel(channel) {
if (!channel) return false;
if (channel.channelId)
@@ -101,9 +108,10 @@ export default definePlugin({
return false;
// check for disallowed voice channels too so that they get hidden when collapsing the category
- channel._isHiddenChannel = !can(VIEW_CHANNEL, channel) || (channel.type === 2 && !can(CONNECT, channel));
+ channel._isHiddenChannel = !PermissionStore.can(VIEW_CHANNEL, channel) || (channel.type === 2 && !PermissionStore.can(CONNECT, channel));
return channel._isHiddenChannel;
},
+
channelSelected(channel) {
if (!channel) return false;
const isHidden = this.isHiddenChannel(channel);
@@ -115,11 +123,7 @@ export default definePlugin({
<ModalHeader>
<Flex>
<Text variant="heading-md/bold">{channel.name}</Text>
- {(channel.isNSFW() && (
- <Text style={{ backgroundColor: "var(--status-danger)", borderRadius: "8px", paddingLeft: 4, paddingRight: 4 }} variant="heading-md/normal">
- NSFW
- </Text>
- ))}
+ {channel.isNSFW() && <Badge text="NSFW" color="var(--status-danger)" />}
</Flex>
</ModalHeader>
<ModalContent style={{ marginBottom: 10, marginTop: 10, marginRight: 8, marginLeft: 8 }}>
@@ -156,5 +160,15 @@ export default definePlugin({
));
}
return isHidden;
- }
+ },
+
+ LockIcon: () => (
+ <svg
+ height="18"
+ width="20"
+ viewBox="0 0 24 24"
+ >
+ <path fill="var(--channel-icon)" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
+ </svg>
+ )
});