Merge branch 'dev' of https://github.com/Vendicated/Vencord into discord-types

This commit is contained in:
ryan-0324 2024-08-30 14:22:11 -04:00
commit 7f3539b595
7 changed files with 90 additions and 34 deletions

View file

@ -73,6 +73,7 @@
"stylelint": "^16.9.0",
"stylelint-config-standard": "^36.0.1",
"ts-patch": "^3.2.1",
"ts-pattern": "5.0.4",
"tsx": "^4.19.0",
"type-fest": "^4.26.0",
"typescript": "^5.5.4",

View file

@ -148,6 +148,9 @@ importers:
ts-patch:
specifier: ^3.2.1
version: 3.2.1
ts-pattern:
specifier: 5.0.4
version: 5.0.4
tsx:
specifier: ^4.19.0
version: 4.19.0
@ -2256,6 +2259,9 @@ packages:
resolution: {integrity: sha512-hlR43v+GUIUy8/ZGFP1DquEqPh7PFKQdDMTAmYt671kCCA6AkDQMoeFaFmZ7ObPLYOmpMgyKUqL1C+coFMf30w==}
hasBin: true
ts-pattern@5.0.4:
resolution: {integrity: sha512-D5iVliqugv2C9541W2CNXFYNEZxr4TiHuLPuf49tKEdQFp/8y8fR0v1RExUvXkiWozKCwE7zv07C6EKxf0lKuQ==}
tslib@2.7.0:
resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==}
@ -4448,6 +4454,8 @@ snapshots:
semver: 7.6.3
strip-ansi: 6.0.1
ts-pattern@5.0.4: {}
tslib@2.7.0: {}
tsx@4.19.0:

View file

@ -65,7 +65,7 @@ export default definePlugin({
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
},
{
match: /({(?=.+?function (\i).{0,120}(\i)=\i\.useMemo.{0,30}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
match: /({(?=.+?function (\i).{0,120}(\i)=\i\.useMemo.{0,60}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})`
}
]

View file

@ -28,6 +28,11 @@ interface IgnoredActivity {
type: ActivitiesTypes;
}
const enum FilterMode {
Whitelist,
Blacklist
}
const RunningGameStore: Store & Record<string, any> = findStoreLazy("RunningGameStore");
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!;
@ -78,14 +83,18 @@ function handleActivityToggle(e: MouseEvent<HTMLButtonElement>, activity: Ignore
if (ignoredActivityIndex === -1) settings.store.ignoredActivities = getIgnoredActivities().concat(activity);
else settings.store.ignoredActivities = getIgnoredActivities().filter((_, index) => index !== ignoredActivityIndex);
// Trigger activities recalculation
recalculateActivities();
}
function recalculateActivities() {
ShowCurrentGame.updateSetting((old: any) => old);
}
const ImportCustomRPCComponent = () => (
<Flex flexDirection="column">
<Forms.FormText type={Forms.FormText.Types.DESCRIPTION}>
Import the application id of the CustomRPC plugin to the allowed list
Import the application id of the CustomRPC plugin to the filter list
</Forms.FormText>
<div>
<Button
@ -96,7 +105,7 @@ const ImportCustomRPCComponent = () => (
return;
}
const isAlreadyAdded = allowedIdsPushID?.(id);
const isAlreadyAdded = idsListPushId?.(id);
if (isAlreadyAdded) {
showToast("CustomRPC application ID is already added.", Toasts.Type.FAILURE);
}
@ -108,39 +117,37 @@ const ImportCustomRPCComponent = () => (
</Flex>
);
let allowedIdsPushID: ((id: string) => boolean) | null = null;
let idsListPushId: ((id: string) => boolean) | null = null;
function AllowedIdsComponent(props: { setValue: (value: string) => void; }) {
const [allowedIds, setAllowedIds] = useState<string>(settings.store.allowedIds ?? "");
function IdsListComponent(props: { setValue: (value: string) => void; }) {
const [idsList, setIdsList] = useState<string>(settings.store.idsList ?? "");
allowedIdsPushID = (id: string) => {
if (!allowedIds.includes(id)) {
const ids = allowedIds + ", " + id;
setAllowedIds(ids);
props.setValue(ids);
return false;
}
return true;
idsListPushId = id => {
if (idsList.includes(id)) return true;
const ids = idsList + ", " + id;
setIdsList(ids);
props.setValue(ids);
return false;
};
useEffect(() => () => {
allowedIdsPushID = null;
idsListPushId = null;
}, []);
function handleChange(newValue: string) {
setAllowedIds(newValue);
setIdsList(newValue);
props.setValue(newValue);
}
return (
<Forms.FormSection>
<Forms.FormTitle tag="h3">Allowed List</Forms.FormTitle>
<Forms.FormTitle tag="h3">Filter List</Forms.FormTitle>
<Forms.FormText className={Margins.bottom8} type={Forms.FormText.Types.DESCRIPTION}>
Comma separated list of activity IDs to allow (Useful for allowing RPC activities and CustomRPC)
Comma separated list of activity IDs to allow (Useful for filtering specific RPC activities and CustomRPC)
</Forms.FormText>
<TextInput
type="text"
value={allowedIds}
value={idsList}
onChange={handleChange}
placeholder="235834946571337729, 343383572805058560"
/>
@ -154,40 +161,62 @@ const settings = definePluginSettings({
description: "",
component: () => <ImportCustomRPCComponent />
},
allowedIds: {
listMode: {
type: OptionType.SELECT,
description: "Change the mode of the filter list",
options: [
{
label: "Whitelist",
value: FilterMode.Whitelist,
default: true
},
{
label: "Blacklist",
value: FilterMode.Blacklist,
}
],
onChange: recalculateActivities
},
idsList: {
type: OptionType.COMPONENT,
description: "",
default: "",
onChange(newValue: string) {
const ids = new Set(newValue.match(/[^,\s](?:[^,]*[^,\s])?/g));
settings.store.allowedIds = [...ids].join(", ");
settings.store.idsList = [...ids].join(", ");
recalculateActivities();
},
component: props => <AllowedIdsComponent setValue={props.setValue} />
component: props => <IdsListComponent setValue={props.setValue} />
},
ignorePlaying: {
type: OptionType.BOOLEAN,
description: "Ignore all playing activities (These are usually game and RPC activities)",
default: false
default: false,
onChange: recalculateActivities
},
ignoreStreaming: {
type: OptionType.BOOLEAN,
description: "Ignore all streaming activities",
default: false
default: false,
onChange: recalculateActivities
},
ignoreListening: {
type: OptionType.BOOLEAN,
description: "Ignore all listening activities (These are usually spotify activities)",
default: false
default: false,
onChange: recalculateActivities
},
ignoreWatching: {
type: OptionType.BOOLEAN,
description: "Ignore all watching activities",
default: false
default: false,
onChange: recalculateActivities
},
ignoreCompeting: {
type: OptionType.BOOLEAN,
description: "Ignore all competing activities (These are normally special game activities)",
default: false
default: false,
onChange: recalculateActivities
}
}).withPrivateSettings<{
ignoredActivities: IgnoredActivity[];
@ -199,8 +228,8 @@ function getIgnoredActivities() {
}
function isActivityTypeIgnored(type: ActivityType, id?: string) {
if (id && settings.store.allowedIds.includes(id)) {
return false;
if (id && settings.store.idsList.includes(id)) {
return settings.store.listMode === FilterMode.Blacklist;
}
switch (type) {
@ -216,7 +245,7 @@ function isActivityTypeIgnored(type: ActivityType, id?: string) {
export default definePlugin({
name: "IgnoreActivities",
authors: [Devs.Nuckyz],
authors: [Devs.Nuckyz, Devs.Kylie],
description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.",
dependencies: ["UserSettingsAPI"],
@ -263,6 +292,12 @@ export default definePlugin({
],
async start() {
// Migrate allowedIds
if (Settings.plugins.IgnoreActivities!.allowedIds) {
settings.store.idsList = Settings.plugins.IgnoreActivities!.allowedIds;
delete Settings.plugins.IgnoreActivities!.allowedIds; // Remove allowedIds
}
const oldIgnoredActivitiesData = await DataStore.get<Map<IgnoredActivity["id"], IgnoredActivity>>("IgnoreActivities_ignoredActivities");
if (oldIgnoredActivitiesData != null) {
@ -292,7 +327,8 @@ export default definePlugin({
if (props.application_id != null) {
return !getIgnoredActivities().some(activity => activity.id === props.application_id)
|| settings.store.allowedIds.includes(props.application_id);
|| settings.store.listMode === FilterMode.Whitelist
&& settings.store.idsList.includes(props.application_id);
} else {
const exePath = RunningGameStore.getRunningGames().find((game: any) => game.name === props.name)?.exePath;
if (exePath) {

View file

@ -22,10 +22,10 @@ export const settings = definePluginSettings({
},
superReactionPlayingLimit: {
description: "Max Super Reactions to play at once",
description: "Max Super Reactions to play at once. 0 to disable playing Super Reactions",
type: OptionType.SLIDER,
default: 20,
markers: [5, 10, 20, 40, 60, 80, 100],
markers: [0, 5, 10, 20, 40, 60, 80, 100],
stickToMarkers: true,
},
}, {
@ -58,6 +58,7 @@ export default definePlugin({
shouldPlayBurstReaction(playingCount: number) {
if (settings.store.unlimitedSuperReactionPlaying) return true;
if (settings.store.superReactionPlayingLimit === 0) return false;
if (playingCount <= settings.store.superReactionPlayingLimit) return true;
return false;
},

View file

@ -534,6 +534,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "Joona",
id: 297410829589020673n
},
Kylie: {
name: "Cookie",
id: 721853658941227088n
},
AshtonMemer: {
name: "AshtonMemer",
id: 373657230530052099n

View file

@ -18,6 +18,7 @@
import type { ChannelMessages as $ChannelMessages, ChannelRecord, Dispatcher, DraftType, FormattedMessage as $FormattedMessage, I18N, MessageFactory, UserRecord } from "@vencord/discord-types";
import type { ReactNode } from "react";
import type { match as $match, P as $P } from "ts-pattern";
// eslint-disable-next-line path-alias/no-relative
import { _resolveReady, filters, findByCodeLazy, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack";
@ -189,6 +190,11 @@ export const RouterUtils: t.RouterUtils = mapMangledModuleLazy("Transitioning to
export let SnowflakeUtils: t.SnowflakeUtils;
waitFor(["fromTimestamp", "extractTimestamp"], m => { SnowflakeUtils = m; });
export const { match, P }: { match: typeof $match; P: typeof $P; } = mapMangledModuleLazy("@ts-pattern/matcher", {
match: filters.byCode("return new"),
P: filters.byProps("when"),
});
export const UploadAttachmentActionCreators = findByPropsLazy("clearAll", "addFile");
export const UserActionCreators = {