Fix ImplicitRelationships

This commit is contained in:
Vendicated 2024-06-19 04:43:21 +02:00
parent d19b0aeb5b
commit 5936e74e7f
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
3 changed files with 7 additions and 11 deletions

View file

@ -19,17 +19,11 @@
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findStoreLazy } from "@webpack"; import { findStoreLazy } from "@webpack";
import { ChannelStore, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common"; import { ChannelStore, Constants, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common";
import { Settings } from "Vencord"; import { Settings } from "Vencord";
const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore"); const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore");
const { FriendsSections } = findByPropsLazy("FriendsSections");
interface UserAffinity {
user_id: string;
affinity: number;
}
export default definePlugin({ export default definePlugin({
name: "ImplicitRelationships", name: "ImplicitRelationships",
@ -70,7 +64,7 @@ export default definePlugin({
}, },
// Piggyback relationship fetch // Piggyback relationship fetch
{ {
find: ".fetchRelationships()", find: '"FriendsStore',
replacement: { replacement: {
match: /(\i\.\i)\.fetchRelationships\(\)/, match: /(\i\.\i)\.fetchRelationships\(\)/,
// This relationship fetch is actually completely useless, but whatevs // This relationship fetch is actually completely useless, but whatevs
@ -182,6 +176,6 @@ export default definePlugin({
}, },
start() { start() {
FriendsSections.IMPLICIT = "IMPLICIT"; Constants.FriendsSections.IMPLICIT = "IMPLICIT";
} }
}); });

View file

@ -219,4 +219,5 @@ export interface IconUtils {
export interface Constants { export interface Constants {
Endpoints: Record<string, any>; Endpoints: Record<string, any>;
UserFlags: Record<string, number>; UserFlags: Record<string, number>;
FriendsSections: Record<string, string>;
} }

View file

@ -40,7 +40,8 @@ waitFor(["dispatchToLastSubscribed"], m => ComponentDispatch = m);
export const Constants: t.Constants = mapMangledModuleLazy('ME:"/users/@me"', { export const Constants: t.Constants = mapMangledModuleLazy('ME:"/users/@me"', {
Endpoints: filters.byProps("USER", "ME"), Endpoints: filters.byProps("USER", "ME"),
UserFlags: filters.byProps("STAFF", "SPAMMER") UserFlags: filters.byProps("STAFF", "SPAMMER"),
FriendsSections: m => m.PENDING === "PENDING" && m.ADD_FRIEND
}); });
export const RestAPI: t.RestAPI = findLazy(m => typeof m === "object" && m.del && m.put); export const RestAPI: t.RestAPI = findLazy(m => typeof m === "object" && m.del && m.put);