mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
disable menu items when user doesn't have nitro
This commit is contained in:
parent
4fc7f6e453
commit
4f5f157625
2 changed files with 20 additions and 14 deletions
|
@ -16,13 +16,16 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./style.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Button, Clickable, Icons, Menu, Toasts, useState } from "@webpack/common";
|
import { Button, Clickable, Icons, Menu, Toasts, UserStore, useState } from "@webpack/common";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
StatusPresets: {
|
StatusPresets: {
|
||||||
|
@ -62,7 +65,7 @@ function StatusIcon({ isHovering, status }: { isHovering: boolean; status: Disco
|
||||||
: (status.emojiInfo != null ? <EmojiComponent emoji={status.emojiInfo} animate={false} hideTooltip={false} /> : <div className={StatusStyles.customEmojiPlaceholder} />)}</div>;
|
: (status.emojiInfo != null ? <EmojiComponent emoji={status.emojiInfo} animate={false} hideTooltip={false} /> : <div className={StatusStyles.customEmojiPlaceholder} />)}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RenderStatusMenuItem = ({ status, forceRerender }: { status: DiscordStatus; forceRerender: () => void; }) => {
|
const RenderStatusMenuItem = ({ status, forceRerender, disabled }: { status: DiscordStatus; forceRerender: () => void; disabled: boolean; }) => {
|
||||||
const [isHovering, setIsHovering] = useState(false);
|
const [isHovering, setIsHovering] = useState(false);
|
||||||
const handleMouseOver = () => {
|
const handleMouseOver = () => {
|
||||||
setIsHovering(true);
|
setIsHovering(true);
|
||||||
|
@ -72,11 +75,7 @@ const RenderStatusMenuItem = ({ status, forceRerender }: { status: DiscordStatus
|
||||||
setIsHovering(false);
|
setIsHovering(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return <div className={StatusStyles.statusItem}
|
return <div className={classes(StatusStyles.statusItem, "vc-sp-item", disabled ? "vc-sp-disabled" : null)}
|
||||||
style={isHovering ? {
|
|
||||||
backgroundColor: "var(--menu-item-default-hover-bg)",
|
|
||||||
color: "var(--white)",
|
|
||||||
} : {}}
|
|
||||||
onMouseOver={handleMouseOver}
|
onMouseOver={handleMouseOver}
|
||||||
onMouseOut={handleMouseOut}>
|
onMouseOut={handleMouseOut}>
|
||||||
<Clickable
|
<Clickable
|
||||||
|
@ -84,11 +83,6 @@ const RenderStatusMenuItem = ({ status, forceRerender }: { status: DiscordStatus
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
delete settings.store.StatusPresets[status.text];
|
delete settings.store.StatusPresets[status.text];
|
||||||
forceRerender();
|
forceRerender();
|
||||||
Toasts.show({
|
|
||||||
message: "Successfully removed Status",
|
|
||||||
type: Toasts.Type.SUCCESS,
|
|
||||||
id: Toasts.genId()
|
|
||||||
});
|
|
||||||
}}><StatusIcon isHovering={isHovering} status={status} /></Clickable>
|
}}><StatusIcon isHovering={isHovering} status={status} /></Clickable>
|
||||||
<div className={StatusStyles.status} style={{ marginLeft: "2px" }}>{status.text}</div>
|
<div className={StatusStyles.status} style={{ marginLeft: "2px" }}>{status.text}</div>
|
||||||
</div >;
|
</div >;
|
||||||
|
@ -102,8 +96,12 @@ const StatusSubMenuComponent = () => {
|
||||||
{Object.entries((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(([index, status]) => <Menu.MenuItem
|
{Object.entries((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(([index, status]) => <Menu.MenuItem
|
||||||
id={"status-presets-" + index}
|
id={"status-presets-" + index}
|
||||||
label={status.status}
|
label={status.status}
|
||||||
action={() => setStatus(status.text, status.emojiInfo, status.clearAfter, { "location": { "section": "Account Panel", "object": "Avatar" } })}
|
action={() => (status.emojiInfo?.id != null && UserStore.getCurrentUser().hasPremiumPerks || status.emojiInfo?.id == null) && setStatus(status.text, status.emojiInfo, status.clearAfter, { "location": { "section": "Account Panel", "object": "Avatar" } })}
|
||||||
render={() => <RenderStatusMenuItem status={status} forceRerender={forceRerender} />}
|
render={() => <RenderStatusMenuItem
|
||||||
|
status={status}
|
||||||
|
forceRerender={forceRerender}
|
||||||
|
disabled={status.emojiInfo?.id != null && !UserStore.getCurrentUser().hasPremiumPerks}
|
||||||
|
/>}
|
||||||
/>)}
|
/>)}
|
||||||
</Menu.Menu>;
|
</Menu.Menu>;
|
||||||
};
|
};
|
||||||
|
|
8
src/plugins/statusPresets/style.css
Normal file
8
src/plugins/statusPresets/style.css
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.vc-sp-disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-sp-item:hover {
|
||||||
|
background-color: var(--menu-item-default-hover-bg) !important;
|
||||||
|
color: var(--white) !important;
|
||||||
|
}
|
Loading…
Reference in a new issue