Nicer GameActivity & SilentMsg UX; Fix [object Object] jumpscare (#863)

This commit is contained in:
Nuckyz 2023-04-10 18:59:48 -03:00 committed by GitHub
parent 40a7aa5079
commit 65f7cf9503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 8 deletions

View file

@ -26,6 +26,7 @@ import definePlugin, { OptionType } from "@utils/types";
import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common"; import { ChannelStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common";
import type { Message } from "discord-types/general"; import type { Message } from "discord-types/general";
import type { ReactNode } from "react";
const DRAFT_TYPE = 0; const DRAFT_TYPE = 0;
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR"); const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
@ -289,8 +290,8 @@ export default definePlugin({
replace: (m, renderableSticker) => `${m}renderableSticker:${renderableSticker},` replace: (m, renderableSticker) => `${m}renderableSticker:${renderableSticker},`
}, },
{ {
match: /emojiSection.{0,50}description:\i(?<=(\i)\.sticker,.+?)(?=,)/, match: /(emojiSection.{0,50}description:)(\i)(?<=(\i)\.sticker,.+?)(?=,)/,
replace: (m, props) => `${m}+(${props}.renderableSticker?.fake?" This is a Fake Nitro sticker. Only you can see it rendered like a real one, for non Vencord users it will show as a link.":"")` replace: (_, rest, reactNode, props) => `${rest}$self.addFakeNotice("STICKER",${reactNode},!!${props}.renderableSticker?.fake)`
} }
] ]
}, },
@ -299,7 +300,7 @@ export default definePlugin({
predicate: () => settings.store.transformEmojis, predicate: () => settings.store.transformEmojis,
replacement: { replacement: {
match: /((\i)=\i\.node,\i=\i\.emojiSourceDiscoverableGuild)(.+?return )(.{0,450}Messages\.EMOJI_POPOUT_PREMIUM_JOINED_GUILD_DESCRIPTION.+?}\))/, match: /((\i)=\i\.node,\i=\i\.emojiSourceDiscoverableGuild)(.+?return )(.{0,450}Messages\.EMOJI_POPOUT_PREMIUM_JOINED_GUILD_DESCRIPTION.+?}\))/,
replace: (_, rest1, node, rest2, messages) => `${rest1},fakeNitroNode=${node}${rest2}(${messages})+(fakeNitroNode.fake?" This is a Fake Nitro emoji. Only you can see it rendered like a real one, for non Vencord users it will show as a link.":"")` replace: (_, rest1, node, rest2, reactNode) => `${rest1},fakeNitroNode=${node}${rest2}$self.addFakeNotice("EMOJI",${reactNode},fakeNitroNode.fake)`
} }
} }
], ],
@ -559,6 +560,25 @@ export default definePlugin({
return link.target && fakeNitroEmojiRegex.test(link.target); return link.target && fakeNitroEmojiRegex.test(link.target);
}, },
addFakeNotice(type: "STICKER" | "EMOJI", node: Array<ReactNode>, fake: boolean) {
if (!fake) return node;
node = Array.isArray(node) ? node : [node];
switch (type) {
case "STICKER": {
node.push(" This is a Fake Nitro sticker. Only you can see it rendered like a real one, for non Vencord users it will show as a link.");
return node;
}
case "EMOJI": {
node.push(" This is a Fake Nitro emoji. Only you can see it rendered like a real one, for non Vencord users it will show as a link.");
return node;
}
}
},
hasPermissionToUseExternalEmojis(channelId: string) { hasPermissionToUseExternalEmojis(channelId: string) {
const channel = ChannelStore.getChannel(channelId); const channel = ChannelStore.getChannel(channelId);

View file

@ -48,7 +48,7 @@ function GameActivityToggleButton() {
return ( return (
<Button <Button
tooltipText="Toggle Game Activity" tooltipText={showCurrentGame ? "Disable Game Activity" : "Enable Game Activity"}
icon={makeIcon(showCurrentGame)} icon={makeIcon(showCurrentGame)}
role="switch" role="switch"
aria-checked={!showCurrentGame} aria-checked={!showCurrentGame}

View file

@ -88,7 +88,7 @@ function ToggleIconOn({ forceWhite }: { forceWhite?: boolean; }) {
); );
} }
function ToggleActivityComponent({ activity, forceWhite }: { activity: IgnoredActivity; forceWhite?: boolean; }) { function ToggleActivityComponent({ activity, forceWhite, forceLeftMargin }: { activity: IgnoredActivity; forceWhite?: boolean; forceLeftMargin?: boolean; }) {
const forceUpdate = useForceUpdater(); const forceUpdate = useForceUpdater();
return ( return (
@ -101,6 +101,7 @@ function ToggleActivityComponent({ activity, forceWhite }: { activity: IgnoredAc
role="button" role="button"
aria-label="Toggle activity" aria-label="Toggle activity"
tabIndex={0} tabIndex={0}
style={forceLeftMargin ? { marginLeft: "2px" } : undefined}
onClick={e => handleActivityToggle(e, activity, forceUpdate)} onClick={e => handleActivityToggle(e, activity, forceUpdate)}
> >
{ {
@ -200,7 +201,7 @@ export default definePlugin({
renderToggleGameActivityButton(props: { id?: string; exePath: string; }) { renderToggleGameActivityButton(props: { id?: string; exePath: string; }) {
return ( return (
<ErrorBoundary noop> <ErrorBoundary noop>
<ToggleActivityComponent activity={{ id: props.id ?? props.exePath, type: ActivitiesTypes.Game }} /> <ToggleActivityComponent activity={{ id: props.id ?? props.exePath, type: ActivitiesTypes.Game }} forceLeftMargin={true} />
</ErrorBoundary> </ErrorBoundary>
); );
}, },

View file

@ -44,7 +44,7 @@ function SilentMessageToggle(chatBoxProps: {
if (chatBoxProps.type.analyticsName !== "normal") return null; if (chatBoxProps.type.analyticsName !== "normal") return null;
return ( return (
<Tooltip text="Toggle Silent Message"> <Tooltip text={enabled ? "Disable Silent Message" : "Enable Silent Message"}>
{tooltipProps => ( {tooltipProps => (
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<Button <Button